Skip to content

Commit

Permalink
fix(Reduce cognitive complexity by splitting out calls): Attempt to r…
Browse files Browse the repository at this point in the history
…educe cognitive complexity rule

Reduce cognitive complexity by splitting code
  • Loading branch information
wayfarer3130 committed Oct 22, 2021
1 parent a507351 commit 6f9887e
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/tools/OverlayTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,8 @@ export default class OverlayTool extends BaseTool {
}
}

renderToolData(evt) {
const eventData = evt.detail;
const { enabledElement, image, viewport, canvasContext } = eventData;

if (!eventData || !enabledElement || !image) {
return;
}

setupRender(image) {
if (!image) return;
const overlayPlaneMetadata = external.cornerstone.metaData.get(
'overlayPlaneModule',
image.imageId
Expand All @@ -66,12 +60,28 @@ export default class OverlayTool extends BaseTool {
return;
}

return overlayPlaneMetadata;
}

setupViewport(viewport) {
if (viewport.overlayColor === undefined) {
viewport.overlayColor =
globalConfiguration.configuration.overlayColor || 'white';
}
// Allow turning off overlays by setting overlayColor to false
if (viewport.overlayColor === false) return;
return true;
}

renderToolData(evt) {
const eventData = evt.detail;
const { enabledElement, image, viewport, canvasContext } = eventData;
const overlayPlaneMetadata = this.setupRender(image);

if (!eventData || !enabledElement || !overlayPlaneMetadata) {
return;
}
if (!this.setupViewport(viewport)) return;

const imageWidth = image.columns;
const imageHeight = image.rows;
Expand Down

0 comments on commit 6f9887e

Please sign in to comment.