@@ -4,7 +4,11 @@ import {
44  getSegmentIdForPosition , 
55  getSegmentIdForPositionAsync , 
66}  from  "viewer/controller/combinations/volume_handlers" ; 
7- import  {  getMappingInfo  }  from  "viewer/model/accessors/dataset_accessor" ; 
7+ import  { 
8+   getMappingInfo , 
9+   getVisibleSegmentationLayer , 
10+ }  from  "viewer/model/accessors/dataset_accessor" ; 
11+ import  {  globalToLayerTransformedPosition  }  from  "viewer/model/accessors/dataset_layer_transformation_accessor" ; 
812import  {  getTreeNameForAgglomerateSkeleton  }  from  "viewer/model/accessors/skeletontracing_accessor" ; 
913import  {  calculateGlobalPos  }  from  "viewer/model/accessors/view_mode_accessor" ; 
1014import  { 
@@ -79,9 +83,22 @@ export function handleClickSegment(clickPosition: Point2) {
7983  const  state  =  Store . getState ( ) ; 
8084  const  globalPosition  =  calculateGlobalPos ( state ,  clickPosition ) ; 
8185  const  segmentId  =  getSegmentIdForPosition ( globalPosition . rounded ) ; 
86+   const  visibleSegmentationLayer  =  getVisibleSegmentationLayer ( state ) ; 
87+   const  positionInSegmentationLayerSpace  = 
88+     visibleSegmentationLayer  !=  null 
89+       ? ( globalToLayerTransformedPosition ( 
90+           globalPosition . rounded , 
91+           visibleSegmentationLayer . name , 
92+           "segmentation" , 
93+           state , 
94+         ) . map ( Math . floor )  as  Vector3 ) 
95+       : null ; 
96+ 
8297  const  {  additionalCoordinates }  =  state . flycam ; 
8398
84-   if  ( segmentId  >  0 )  { 
85-     Store . dispatch ( clickSegmentAction ( segmentId ,  globalPosition . rounded ,  additionalCoordinates ) ) ; 
99+   if  ( segmentId  >  0  &&  positionInSegmentationLayerSpace  !=  null )  { 
100+     Store . dispatch ( 
101+       clickSegmentAction ( segmentId ,  positionInSegmentationLayerSpace ,  additionalCoordinates ) , 
102+     ) ; 
86103  } 
87104} 
0 commit comments