@@ -74,7 +74,7 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
7474 sliceCenter : [ ] ,
7575 } ;
7676
77- function updateScrollManipulator ( ) {
77+ publicAPI . updateScrollManipulator = ( ) => {
7878 const range = publicAPI . getSliceRange ( ) ;
7979 model . scrollManipulator . removeScrollListener ( ) ;
8080 // The Scroll listener has min, max, step, and getValue setValue as params.
@@ -86,15 +86,15 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
8686 publicAPI . getSlice ,
8787 publicAPI . scrollToSlice
8888 ) ;
89- }
89+ } ;
9090
9191 function setManipulators ( ) {
9292 publicAPI . removeAllMouseManipulators ( ) ;
9393 publicAPI . addMouseManipulator ( model . trackballManipulator ) ;
9494 publicAPI . addMouseManipulator ( model . panManipulator ) ;
9595 publicAPI . addMouseManipulator ( model . zoomManipulator ) ;
9696 publicAPI . addMouseManipulator ( model . scrollManipulator ) ;
97- updateScrollManipulator ( ) ;
97+ publicAPI . updateScrollManipulator ( ) ;
9898 }
9999
100100 function isCameraViewInitialized ( camera ) {
@@ -219,7 +219,7 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
219219 const camera = renderer . getActiveCamera ( ) ;
220220
221221 cameraSub = camera . onModified ( ( ) => {
222- updateScrollManipulator ( ) ;
222+ publicAPI . updateScrollManipulator ( ) ;
223223 publicAPI . modified ( ) ;
224224 } ) ;
225225
@@ -238,7 +238,7 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
238238 // TODO -> When we want a modular framework we'll have to rethink all this.
239239 // TODO -> We need to think of a more generic way to do this for all widget types eventually.
240240 // TODO -> We certainly need to be able to register widget types on instantiation.
241- function handleButtonPress ( ) {
241+ function handleButtonPress ( callData ) {
242242 const { apis, apiIndex } = model ;
243243
244244 if ( apis && apis [ apiIndex ] && apis [ apiIndex ] . type === 'VIEW2D' ) {
@@ -250,11 +250,33 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
250250 api . svgWidgets . crosshairsWidget . updateCrosshairForApi ( api ) ;
251251 }
252252 if ( api . svgWidgets . rotatableCrosshairsWidget ) {
253- api . svgWidgets . rotatableCrosshairsWidget . updateCrosshairForApi ( api ) ;
253+ updateRotatableCrosshairs ( callData ) ;
254254 }
255255 }
256256 }
257257
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+
258280 publicAPI . handleMiddleButtonPress = macro . chain (
259281 publicAPI . handleMiddleButtonPress ,
260282 handleButtonPress
@@ -280,12 +302,12 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
280302 api . svgWidgets . crosshairsWidget . updateCrosshairForApi ( api ) ;
281303 }
282304 if ( api . svgWidgets . rotatableCrosshairsWidget ) {
283- api . svgWidgets . rotatableCrosshairsWidget . updateCrosshairForApi ( api ) ;
305+ updateRotatableCrosshairs ( callData ) ;
284306 }
285307 }
286308 } ;
287309
288- function handleButtonRelease ( superButtonRelease ) {
310+ function handleButtonRelease ( superButtonRelease , callData ) {
289311 if ( model . state === States . IS_PAN ) {
290312 publicAPI . endPan ( ) ;
291313 const { apis, apiIndex } = model ;
@@ -295,7 +317,7 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
295317 api . svgWidgets . crosshairsWidget . updateCrosshairForApi ( api ) ;
296318 }
297319 if ( api . svgWidgets . rotatableCrosshairsWidget ) {
298- api . svgWidgets . rotatableCrosshairsWidget . updateCrosshairForApi ( api ) ;
320+ updateRotatableCrosshairs ( callData ) ;
299321 }
300322 }
301323
@@ -304,13 +326,13 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
304326
305327 publicAPI . superHandleMiddleButtonRelease =
306328 publicAPI . handleMiddleButtonRelease ;
307- publicAPI . handleMiddleButtonRelease = ( ) => {
308- handleButtonRelease ( publicAPI . superHandleMiddleButtonRelease ) ;
329+ publicAPI . handleMiddleButtonRelease = callData => {
330+ handleButtonRelease ( publicAPI . superHandleMiddleButtonRelease , callData ) ;
309331 } ;
310332
311333 publicAPI . superHandleRightButtonRelease = publicAPI . handleRightButtonRelease ;
312- publicAPI . handleRightButtonRelease = ( ) => {
313- handleButtonRelease ( publicAPI . superHandleRightButtonRelease ) ;
334+ publicAPI . handleRightButtonRelease = callData => {
335+ handleButtonRelease ( publicAPI . superHandleRightButtonRelease , callData ) ;
314336 } ;
315337
316338 publicAPI . setVolumeActor = actor => {
@@ -328,7 +350,7 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
328350 setViewUpInternal ( viewportData . getCurrentViewUp ( ) ) ;
329351 }
330352
331- updateScrollManipulator ( ) ;
353+ publicAPI . updateScrollManipulator ( ) ;
332354 // NOTE: Disabling this because it makes it more difficult to switch
333355 // interactor styles. Need to find a better way to do this!
334356 //publicAPI.setSliceNormal(...publicAPI.getSliceNormal());
0 commit comments