@@ -74,7 +74,7 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
74
74
sliceCenter : [ ] ,
75
75
} ;
76
76
77
- function updateScrollManipulator ( ) {
77
+ publicAPI . updateScrollManipulator = ( ) => {
78
78
const range = publicAPI . getSliceRange ( ) ;
79
79
model . scrollManipulator . removeScrollListener ( ) ;
80
80
// The Scroll listener has min, max, step, and getValue setValue as params.
@@ -86,15 +86,15 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
86
86
publicAPI . getSlice ,
87
87
publicAPI . scrollToSlice
88
88
) ;
89
- }
89
+ } ;
90
90
91
91
function setManipulators ( ) {
92
92
publicAPI . removeAllMouseManipulators ( ) ;
93
93
publicAPI . addMouseManipulator ( model . trackballManipulator ) ;
94
94
publicAPI . addMouseManipulator ( model . panManipulator ) ;
95
95
publicAPI . addMouseManipulator ( model . zoomManipulator ) ;
96
96
publicAPI . addMouseManipulator ( model . scrollManipulator ) ;
97
- updateScrollManipulator ( ) ;
97
+ publicAPI . updateScrollManipulator ( ) ;
98
98
}
99
99
100
100
function isCameraViewInitialized ( camera ) {
@@ -219,7 +219,7 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
219
219
const camera = renderer . getActiveCamera ( ) ;
220
220
221
221
cameraSub = camera . onModified ( ( ) => {
222
- updateScrollManipulator ( ) ;
222
+ publicAPI . updateScrollManipulator ( ) ;
223
223
publicAPI . modified ( ) ;
224
224
} ) ;
225
225
@@ -238,7 +238,7 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
238
238
// TODO -> When we want a modular framework we'll have to rethink all this.
239
239
// TODO -> We need to think of a more generic way to do this for all widget types eventually.
240
240
// TODO -> We certainly need to be able to register widget types on instantiation.
241
- function handleButtonPress ( ) {
241
+ function handleButtonPress ( callData ) {
242
242
const { apis, apiIndex } = model ;
243
243
244
244
if ( apis && apis [ apiIndex ] && apis [ apiIndex ] . type === 'VIEW2D' ) {
@@ -250,11 +250,33 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
250
250
api . svgWidgets . crosshairsWidget . updateCrosshairForApi ( api ) ;
251
251
}
252
252
if ( api . svgWidgets . rotatableCrosshairsWidget ) {
253
- api . svgWidgets . rotatableCrosshairsWidget . updateCrosshairForApi ( api ) ;
253
+ updateRotatableCrosshairs ( callData ) ;
254
254
}
255
255
}
256
256
}
257
257
258
+ function updateRotatableCrosshairs ( callData ) {
259
+ const { apis, apiIndex } = model ;
260
+ const thisApi = apis [ apiIndex ] ;
261
+ const { rotatableCrosshairsWidget } = thisApi . svgWidgets ;
262
+ const renderer = callData . pokedRenderer ;
263
+ const worldPos = thisApi . get ( 'cachedCrosshairWorldPosition' ) ;
264
+
265
+ const camera = renderer . getActiveCamera ( ) ;
266
+ const directionOfProjection = camera . getDirectionOfProjection ( ) ;
267
+
268
+ const halfSlabThickness = thisApi . getSlabThickness ( ) / 2 ;
269
+
270
+ // Add half of the slab thickness to the world position, such that we select
271
+ // The center of the slice.
272
+
273
+ for ( let i = 0 ; i < worldPos . length ; i ++ ) {
274
+ worldPos [ i ] += halfSlabThickness * directionOfProjection [ i ] ;
275
+ }
276
+
277
+ rotatableCrosshairsWidget . moveCrosshairs ( worldPos , apis , apiIndex ) ;
278
+ }
279
+
258
280
publicAPI . handleMiddleButtonPress = macro . chain (
259
281
publicAPI . handleMiddleButtonPress ,
260
282
handleButtonPress
@@ -280,12 +302,12 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
280
302
api . svgWidgets . crosshairsWidget . updateCrosshairForApi ( api ) ;
281
303
}
282
304
if ( api . svgWidgets . rotatableCrosshairsWidget ) {
283
- api . svgWidgets . rotatableCrosshairsWidget . updateCrosshairForApi ( api ) ;
305
+ updateRotatableCrosshairs ( callData ) ;
284
306
}
285
307
}
286
308
} ;
287
309
288
- function handleButtonRelease ( superButtonRelease ) {
310
+ function handleButtonRelease ( superButtonRelease , callData ) {
289
311
if ( model . state === States . IS_PAN ) {
290
312
publicAPI . endPan ( ) ;
291
313
const { apis, apiIndex } = model ;
@@ -295,7 +317,7 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
295
317
api . svgWidgets . crosshairsWidget . updateCrosshairForApi ( api ) ;
296
318
}
297
319
if ( api . svgWidgets . rotatableCrosshairsWidget ) {
298
- api . svgWidgets . rotatableCrosshairsWidget . updateCrosshairForApi ( api ) ;
320
+ updateRotatableCrosshairs ( callData ) ;
299
321
}
300
322
}
301
323
@@ -304,13 +326,13 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
304
326
305
327
publicAPI . superHandleMiddleButtonRelease =
306
328
publicAPI . handleMiddleButtonRelease ;
307
- publicAPI . handleMiddleButtonRelease = ( ) => {
308
- handleButtonRelease ( publicAPI . superHandleMiddleButtonRelease ) ;
329
+ publicAPI . handleMiddleButtonRelease = callData => {
330
+ handleButtonRelease ( publicAPI . superHandleMiddleButtonRelease , callData ) ;
309
331
} ;
310
332
311
333
publicAPI . superHandleRightButtonRelease = publicAPI . handleRightButtonRelease ;
312
- publicAPI . handleRightButtonRelease = ( ) => {
313
- handleButtonRelease ( publicAPI . superHandleRightButtonRelease ) ;
334
+ publicAPI . handleRightButtonRelease = callData => {
335
+ handleButtonRelease ( publicAPI . superHandleRightButtonRelease , callData ) ;
314
336
} ;
315
337
316
338
publicAPI . setVolumeActor = actor => {
@@ -328,7 +350,7 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
328
350
setViewUpInternal ( viewportData . getCurrentViewUp ( ) ) ;
329
351
}
330
352
331
- updateScrollManipulator ( ) ;
353
+ publicAPI . updateScrollManipulator ( ) ;
332
354
// NOTE: Disabling this because it makes it more difficult to switch
333
355
// interactor styles. Need to find a better way to do this!
334
356
//publicAPI.setSliceNormal(...publicAPI.getSliceNormal());
0 commit comments