-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(windowlevelreset): add an option to reset the window width/level…
… values
- Loading branch information
Showing
11 changed files
with
82 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
function applyWindowLevelReset(context, { data }) { | ||
const actorContext = context.images.actorContext.get(data.name) | ||
const component = actorContext.selectedComponent | ||
const bounds = actorContext.colorRangeBounds.get(component) | ||
|
||
const wMax = bounds[1] - bounds[0] | ||
const lMin = bounds[0] | ||
const level = wMax / 2 + lMin | ||
const width = wMax | ||
|
||
const newRange = () => { | ||
return [level - width / 2, level + width / 2] | ||
} | ||
|
||
context.service.send({ | ||
type: 'IMAGE_COLOR_RANGE_CHANGED', | ||
data: { | ||
name: data.name, | ||
component, | ||
range: newRange(), | ||
}, | ||
}) | ||
} | ||
|
||
export default applyWindowLevelReset |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import style from '../ItkVtkViewer.module.css' | ||
import applyContrastSensitiveStyleToElement from '../applyContrastSensitiveStyleToElement' | ||
|
||
import { resetImageIconDataUri } from 'itk-viewer-icons' | ||
|
||
function createWindowLevelReset(context, uiContainer) { | ||
const windowLevelResetButton = document.createElement('div') | ||
windowLevelResetButton.innerHTML = ` | ||
<div itk-vtk-tooltip itk-vtk-tooltip-left itk-vtk-tooltip-content="Reset range to ROI" class="${style.windowLevelButton}"> | ||
<img src="${resetImageIconDataUri}" alt="gradient opacity"/> | ||
</div> | ||
` | ||
const windowLevelResetButtonInput = windowLevelResetButton.children[0] | ||
const windowLevelResetButtonLabel = windowLevelResetButton.children[1] | ||
applyContrastSensitiveStyleToElement( | ||
context, | ||
'invertibleButton', | ||
windowLevelResetButtonLabel | ||
) | ||
context.images.windowLevelResetButtonLabel = windowLevelResetButtonLabel | ||
context.images.windowLevelResetButtonInput = windowLevelResetButtonInput | ||
|
||
windowLevelResetButton.addEventListener('click', event => { | ||
event.preventDefault() | ||
event.stopPropagation() | ||
context.service.send({ | ||
type: 'IMAGE_COLOR_RANGE_RESET', | ||
data: { | ||
name: context.images.selectedName, | ||
}, | ||
}) | ||
}) | ||
uiContainer.appendChild(windowLevelResetButton) | ||
} | ||
|
||
export default createWindowLevelReset |
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