-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a SmartScrollbar component to show cached slices in each disp…
…layset and added an extra feature to prevent scrolling to uncached slices.
- Loading branch information
1 parent
83f3bf4
commit d781297
Showing
20 changed files
with
357 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
extensions/cornerstone/src/tools/SmartStackScrollMouseWheelTool.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { getEnabledElement } from '@cornerstonejs/core'; | ||
import { StackScrollMouseWheelTool, Types } from '@cornerstonejs/tools'; | ||
|
||
class SmartStackScrollMouseWheelTool extends StackScrollMouseWheelTool { | ||
parentMouseWheelCallback: (evt: Types.EventTypes.MouseWheelEventType) => void; | ||
|
||
constructor(toolProps, defaultToolProps) { | ||
super(toolProps, defaultToolProps); | ||
this.parentMouseWheelCallback = this.mouseWheelCallback; | ||
this.mouseWheelCallback = this.smartMouseWheelCallback; | ||
} | ||
|
||
smartMouseWheelCallback(evt: Types.EventTypes.MouseWheelEventType): void { | ||
const { wheel, element } = evt.detail; | ||
const { direction } = wheel; | ||
const { invert, shouldPreventScroll } = this.configuration; | ||
const { viewport } = getEnabledElement(element); | ||
const delta = direction * (invert ? -1 : 1); | ||
|
||
if (shouldPreventScroll(evt.detail.event.ctrlKey, viewport.getCurrentImageIdIndex() + delta)) { | ||
return; | ||
} | ||
|
||
this.parentMouseWheelCallback(evt); | ||
} | ||
} | ||
|
||
SmartStackScrollMouseWheelTool.toolName = 'SmartStackScrollMouseWheel'; | ||
export default SmartStackScrollMouseWheelTool; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { getEnabledElementByIds } from '@cornerstonejs/core'; | ||
import { StackScrollTool, Types } from '@cornerstonejs/tools'; | ||
|
||
class SmartStackScrollTool extends StackScrollTool { | ||
parentDragCallback: (evt: Types.EventTypes.InteractionEventType) => void; | ||
|
||
constructor(toolProps, defaultToolProps) { | ||
super(toolProps, defaultToolProps); | ||
this.parentDragCallback = this._dragCallback; | ||
this._dragCallback = this._smartDragCallback; | ||
} | ||
|
||
_smartDragCallback(evt: Types.EventTypes.InteractionEventType) { | ||
const { deltaPoints, viewportId, renderingEngineId } = evt.detail; | ||
const { viewport } = getEnabledElementByIds(viewportId, renderingEngineId); | ||
const { invert, shouldPreventScroll } = this.configuration; | ||
const deltaPointY = deltaPoints.canvas[1]; | ||
const pixelsPerImage = this._getPixelPerImage(viewport); | ||
const deltaY = deltaPointY + this.deltaY; | ||
const imageIdIndexOffset = Math.round(deltaY / pixelsPerImage); | ||
const delta = invert ? -imageIdIndexOffset : imageIdIndexOffset; | ||
|
||
if (shouldPreventScroll(evt.detail.event.ctrlKey, viewport.getCurrentImageIdIndex() + delta)) { | ||
return; | ||
} | ||
|
||
return this.parentDragCallback(evt); | ||
} | ||
} | ||
|
||
SmartStackScrollTool.toolName = 'SmartStackScroll'; | ||
export default SmartStackScrollTool; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export default function shouldPreventScroll( | ||
keyPressed: boolean, | ||
imageIdIndex: number, | ||
servicesManager | ||
): boolean { | ||
const { stateSyncService, viewportGridService } = servicesManager.services; | ||
const { cachedSlicesPerSeries } = stateSyncService.getState(); | ||
const { activeViewportId, viewports } = viewportGridService.getState(); | ||
const cachedSlices = cachedSlicesPerSeries[ | ||
viewports.get(activeViewportId).displaySetInstanceUIDs[0] | ||
] as number[]; | ||
|
||
if (!cachedSlices) { | ||
return false; | ||
} | ||
|
||
return !keyPressed && !cachedSlices.includes(imageIdIndex); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.scroll { | ||
height: calc(100% - 30px); | ||
padding: 5px; | ||
padding-left: 0; | ||
position: absolute; | ||
right: 0; | ||
top: 30px; | ||
|
Oops, something went wrong.