@@ -46,7 +46,7 @@ import {
46
46
} from "oxalis/model/accessors/dataset_layer_transformation_accessor" ;
47
47
import { getActiveMagIndicesForLayers , getPosition } from "oxalis/model/accessors/flycam_accessor" ;
48
48
import { getSkeletonTracing } from "oxalis/model/accessors/skeletontracing_accessor" ;
49
- import { getSomeTracing } from "oxalis/model/accessors/tracing_accessor" ;
49
+ import { getSomeTracing , getTaskBoundingBoxes } from "oxalis/model/accessors/tracing_accessor" ;
50
50
import { getPlaneScalingFactor } from "oxalis/model/accessors/view_mode_accessor" ;
51
51
import { sceneControllerReadyAction } from "oxalis/model/actions/actions" ;
52
52
import Dimensions from "oxalis/model/dimensions" ;
@@ -84,7 +84,7 @@ class SceneController {
84
84
layerBoundingBoxes ! : { [ layerName : string ] : Cube } ;
85
85
annotationToolsGeometryGroup ! : THREE . Group ;
86
86
highlightedBBoxId : number | null | undefined ;
87
- taskBoundingBox : Cube | null | undefined ;
87
+ taskCubeByTracingId : Record < string , Cube | null | undefined > = { } ;
88
88
contour ! : ContourGeometry ;
89
89
quickSelectGeometry ! : QuickSelectGeometry ;
90
90
lineMeasurementGeometry ! : LineMeasurementGeometry ;
@@ -231,6 +231,7 @@ class SceneController {
231
231
showCrossSections : true ,
232
232
isHighlighted : false ,
233
233
} ) ;
234
+ this . datasetBoundingBox . getMeshes ( ) . forEach ( ( mesh ) => this . rootNode . add ( mesh ) ) ;
234
235
235
236
this . contour = new ContourGeometry ( ) ;
236
237
this . quickSelectGeometry = new QuickSelectGeometry ( ) ;
@@ -260,8 +261,6 @@ class SceneController {
260
261
...planeMeshes ,
261
262
) ;
262
263
263
- const taskBoundingBox = getSomeTracing ( state . annotation ) . boundingBox ;
264
- this . buildTaskingBoundingBox ( taskBoundingBox ) ;
265
264
if ( state . annotation . skeleton != null ) {
266
265
this . addSkeleton ( ( _state ) => getSkeletonTracing ( _state . annotation ) , true ) ;
267
266
}
@@ -326,24 +325,48 @@ class SceneController {
326
325
this . rootNode . remove ( skeletonGroup ) ;
327
326
}
328
327
329
- buildTaskingBoundingBox ( taskBoundingBox : BoundingBoxType | null | undefined ) : void {
330
- if ( taskBoundingBox != null ) {
331
- if ( this . taskBoundingBox != null ) {
332
- this . taskBoundingBox . getMeshes ( ) . forEach ( ( mesh ) => this . rootNode . remove ( mesh ) ) ;
328
+ updateTaskBoundingBoxes (
329
+ taskCubeByTracingId : Record < string , BoundingBoxType | null | undefined > ,
330
+ ) : void {
331
+ /*
332
+ Ensures that a green task bounding box is rendered in the scene for
333
+ each layer.
334
+ The update is implemented by simply removing the old geometry and
335
+ adding a new one. Since this function is executed very rarely,
336
+ this is not a performance problem.
337
+ */
338
+ for ( const [ tracingId , boundingBox ] of Object . entries ( taskCubeByTracingId ) ) {
339
+ let taskCube = this . taskCubeByTracingId [ tracingId ] ;
340
+ // Remove the old box if it exists
341
+ if ( taskCube != null ) {
342
+ taskCube . getMeshes ( ) . forEach ( ( mesh ) => this . rootNode . remove ( mesh ) ) ;
343
+ }
344
+ this . taskCubeByTracingId [ tracingId ] = null ;
345
+ if ( boundingBox == null || Store . getState ( ) . task == null ) {
346
+ continue ;
333
347
}
334
-
335
348
const { viewMode } = Store . getState ( ) . temporaryConfiguration ;
336
- this . taskBoundingBox = new Cube ( {
337
- min : taskBoundingBox . min ,
338
- max : taskBoundingBox . max ,
349
+ taskCube = new Cube ( {
350
+ min : boundingBox . min ,
351
+ max : boundingBox . max ,
339
352
color : 0x00ff00 ,
340
353
showCrossSections : true ,
341
354
isHighlighted : false ,
342
355
} ) ;
343
- this . taskBoundingBox . getMeshes ( ) . forEach ( ( mesh ) => this . rootNode . add ( mesh ) ) ;
356
+ taskCube . getMeshes ( ) . forEach ( ( mesh ) => this . rootNode . add ( mesh ) ) ;
344
357
345
358
if ( constants . MODES_ARBITRARY . includes ( viewMode ) ) {
346
- this . taskBoundingBox ?. setVisibility ( false ) ;
359
+ taskCube ?. setVisibility ( false ) ;
360
+ }
361
+
362
+ this . taskCubeByTracingId [ tracingId ] = taskCube ;
363
+ }
364
+ }
365
+
366
+ forEachTaskCube ( fn : ( cube : Cube ) => void ) {
367
+ for ( const cube of Object . values ( this . taskCubeByTracingId ) ) {
368
+ if ( cube != null ) {
369
+ fn ( cube ) ;
347
370
}
348
371
}
349
372
}
@@ -369,7 +392,7 @@ class SceneController {
369
392
bbCube . updateForCam ( id ) ;
370
393
} ) ;
371
394
372
- this . taskBoundingBox ? .updateForCam ( id ) ;
395
+ this . forEachTaskCube ( ( cube ) => cube . updateForCam ( id ) ) ;
373
396
374
397
this . segmentMeshController . meshesLayerLODRootGroup . visible = id === OrthoViews . TDView ;
375
398
if ( this . splitBoundaryMesh != null ) {
@@ -623,8 +646,7 @@ class SceneController {
623
646
624
647
this . datasetBoundingBox . setVisibility ( false ) ;
625
648
this . userBoundingBoxGroup . visible = false ;
626
-
627
- this . taskBoundingBox ?. setVisibility ( false ) ;
649
+ this . forEachTaskCube ( ( cube ) => cube . setVisibility ( false ) ) ;
628
650
629
651
if ( this . segmentMeshController . meshesLayerLODRootGroup != null ) {
630
652
this . segmentMeshController . meshesLayerLODRootGroup . visible = false ;
@@ -639,7 +661,7 @@ class SceneController {
639
661
this . datasetBoundingBox . setVisibility ( true ) ;
640
662
this . userBoundingBoxGroup . visible = true ;
641
663
642
- this . taskBoundingBox ? .setVisibility ( true ) ;
664
+ this . forEachTaskCube ( ( cube ) => cube . setVisibility ( true ) ) ;
643
665
}
644
666
645
667
destroy ( ) {
@@ -670,7 +692,7 @@ class SceneController {
670
692
this . datasetBoundingBox . destroy ( ) ;
671
693
this . userBoundingBoxes . forEach ( ( cube ) => cube . destroy ( ) ) ;
672
694
Object . values ( this . layerBoundingBoxes ) . forEach ( ( cube ) => cube . destroy ( ) ) ;
673
- this . taskBoundingBox ? .destroy ( ) ;
695
+ this . forEachTaskCube ( ( cube ) => cube . destroy ( ) ) ;
674
696
675
697
for ( const plane of _ . values ( this . planes ) ) {
676
698
plane . destroy ( ) ;
@@ -712,8 +734,9 @@ class SceneController {
712
734
this . updateMeshesAccordingToLayerVisibility ( ) ,
713
735
) ,
714
736
listenToStoreProperty (
715
- ( storeState ) => getSomeTracing ( storeState . annotation ) . boundingBox ,
716
- ( bb ) => this . buildTaskingBoundingBox ( bb ) ,
737
+ ( storeState ) => getTaskBoundingBoxes ( storeState . annotation ) ,
738
+ ( boundingBoxesByTracingId ) => this . updateTaskBoundingBoxes ( boundingBoxesByTracingId ) ,
739
+ true ,
717
740
) ,
718
741
listenToStoreProperty (
719
742
( storeState ) =>
0 commit comments