fix(SegmentationPanel): should be able to hide and only show one segment (#3270)

* fix(SegmentationPanel): should be able to hide and only show one segment

* fix imports

* bump package versions
This commit is contained in:
Alireza 2023-03-22 12:44:52 -04:00 committed by GitHub
parent 3b6822e7b6
commit 4e94b588a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 71 additions and 75 deletions

View File

@ -46,7 +46,7 @@
"@babel/runtime": "^7.20.13",
"classnames": "^2.3.2",
"@cornerstonejs/adapters": "^0.4.1",
"@cornerstonejs/core": "^0.36.0",
"@cornerstonejs/tools": "^0.50.2"
"@cornerstonejs/core": "^0.36.2",
"@cornerstonejs/tools": "^0.55.1"
}
}

View File

@ -44,9 +44,9 @@
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^0.4.1",
"@cornerstonejs/core": "^0.36.0",
"@cornerstonejs/streaming-image-volume-loader": "^0.14.1",
"@cornerstonejs/tools": "^0.50.2",
"@cornerstonejs/core": "^0.36.2",
"@cornerstonejs/streaming-image-volume-loader": "^0.15.1",
"@cornerstonejs/tools": "^0.55.1",
"@kitware/vtk.js": "26.5.6",
"html2canvas": "^1.4.1",
"lodash.debounce": "4.0.8",

View File

@ -151,5 +151,6 @@ const cornerstoneExtension: Types.Extensions.Extension = {
},
};
export type { PublicViewportOptions };
export { measurementMappingUtils };
export default cornerstoneExtension;
export { measurementMappingUtils, PublicViewportOptions };

View File

@ -1,22 +1,22 @@
import cloneDeep from 'lodash.clonedeep';
import { pubSubServiceInterface } from '@ohif/core';
import {
utilities as cstUtils,
segmentation as cstSegmentation,
CONSTANTS as cstConstants,
Enums as csToolsEnums,
Types as cstTypes,
} from '@cornerstonejs/tools';
import {
eventTarget,
cache,
eventTarget,
getEnabledElementByIds,
metaData,
Types,
utilities as csUtils,
volumeLoader,
Types,
metaData,
getEnabledElementByIds,
} from '@cornerstonejs/core';
import {
CONSTANTS as cstConstants,
Enums as csToolsEnums,
segmentation as cstSegmentation,
Types as cstTypes,
utilities as cstUtils,
} from '@cornerstonejs/tools';
import { pubSubServiceInterface } from '@ohif/core';
import isEqual from 'lodash.isequal';
import { easeInOutBell } from '../../utils/transitions';
import {
@ -202,7 +202,7 @@ class SegmentationService {
this._setActiveSegment(segmentationId, segmentIndex, suppressEvents);
}
// Todo: this includes nonhydrated segmentations which might not be
// Todo: this includes non-hydrated segmentations which might not be
// persisted in the store
this._broadcastEvent(this.EVENTS.SEGMENTATION_UPDATED, {
segmentation,
@ -1598,6 +1598,13 @@ class SegmentationService {
isVisible
);
// make sure to update the isVisible flag on the segmentation
// if a segment becomes invisible then the segmentation should be invisible
// in the status as well, and show correct icon
segmentation.isVisible = segmentation.segments
.filter(Boolean)
.every(segment => segment.isVisible);
if (suppressEvents === false) {
this._broadcastEvent(this.EVENTS.SEGMENTATION_UPDATED, {
segmentation,
@ -1917,28 +1924,27 @@ class SegmentationService {
representation => representation.segmentationId === segmentationId
);
const visibility = cstSegmentation.config.visibility.getSegmentationVisibility(
toolGroupId,
representation.segmentationRepresentationUID
);
const { segmentsHidden } = representation;
const currentVisibility = segmentsHidden.size === 0 ? true : false;
const newVisibility = !currentVisibility;
cstSegmentation.config.visibility.setSegmentationVisibility(
toolGroupId,
representation.segmentationRepresentationUID,
!visibility
newVisibility
);
// set all segments to visible as well
const segments = this.getSegmentation(segmentationId).segments;
Object.keys(segments).forEach(segmentIndex => {
if (segmentIndex !== '0') {
this._setSegmentVisibility(
segmentationId,
Number(segmentIndex),
!visibility,
toolGroupId
);
}
// update segments visibility
const { segmentation } = this._getSegmentationInfo(
segmentationId,
toolGroupId
);
const segments = segmentation.segments.filter(Boolean);
segments.forEach(segment => {
segment.isVisible = newVisibility;
});
});
};

View File

@ -1,14 +1,14 @@
import { Types, Enums } from '@cornerstonejs/core';
import { Types as UITypes } from '@ohif/ui';
import {
StackViewportData,
VolumeViewportData,
} from '../../types/CornerstoneCacheService';
import getCornerstoneBlendMode from '../../utils/getCornerstoneBlendMode';
import getCornerstoneOrientation from '../../utils/getCornerstoneOrientation';
import getCornerstoneViewportType from '../../utils/getCornerstoneViewportType';
import JumpPresets from '../../utils/JumpPresets';
import { SyncGroup } from '../SyncGroupService/SyncGroupService';
import {
StackViewportData,
VolumeViewportData,
} from '../../types/CornerstoneCacheService';
export type InitialImageOptions = {
index?: number;
@ -247,7 +247,7 @@ class ViewportInfo {
return this.viewportOptions.background || [0, 0, 0];
}
public getOrientation(): Types.Orientation {
public getOrientation(): Enums.OrientationAxis {
return this.viewportOptions.orientation;
}

View File

@ -1,5 +1,4 @@
import { Enums } from '@cornerstonejs/core';
import { log } from '@ohif/core';
const AXIAL = 'axial';
const SAGITTAL = 'sagittal';

View File

@ -32,8 +32,8 @@
"peerDependencies": {
"@ohif/core": "^3.0.0",
"classnames": "^2.3.2",
"@cornerstonejs/core": "^0.36.0",
"@cornerstonejs/tools": "^0.50.2",
"@cornerstonejs/core": "^0.36.2",
"@cornerstonejs/tools": "^0.55.1",
"@ohif/extension-cornerstone-dicom-sr": "^3.0.0",
"dcmjs": "^0.29.4",
"lodash.debounce": "^4.17.21",

View File

@ -171,9 +171,7 @@ const SegmentationGroup = ({
id={id}
showAddSegment={showAddSegment}
/>
<div
className="flex flex-col min-h-0 ohif-scrollbar overflow-y-hidden"
>
<div className="flex flex-col min-h-0 ohif-scrollbar overflow-y-hidden">
{!!segments.length &&
segments.map(segment => {
if (segment === undefined || segment === null) {

View File

@ -1443,44 +1443,36 @@
resolved "https://registry.npmjs.org/@cornerstonejs/codec-openjph/-/codec-openjph-2.4.2.tgz#e96721d56f6ec96f7f95c16321d88cc8467d8d81"
integrity sha512-lgdvBvvNezleY+4pIe2ceUsJzlZe/0PipdeubQ3vZZOz3xxtHHMR1XFCl4fgd8gosR8COHuD7h6q+MwgrwBsng==
"@cornerstonejs/core@^0.33.1":
version "0.33.1"
resolved "https://registry.yarnpkg.com/@cornerstonejs/core/-/core-0.33.1.tgz#dfbcad81239141c2702fd2ab0a3edbe408e7bfad"
integrity sha512-QXrnKZBEMharA/FIYqtvkTXD8JeEf742yHybNmehB1cJU1hrsjRJ1JuqXXu6IHWJFx3cAsCaWk4oZyA09OB7OQ==
"@cornerstonejs/core@^0.35.1":
version "0.35.1"
resolved "https://registry.npmjs.org/@cornerstonejs/core/-/core-0.35.1.tgz#fd5e9f878b51807366d9d0c6659ac91b43efed87"
integrity sha512-n6nFo3XVkMKmhNsF20yPznO3jo3MpOl8X+3k/HyHVlZujIsBT/jz0X4dEg/3fzA0aLPdWdZ/kkVw8TBanVKTGA==
dependencies:
detect-gpu "^4.0.45"
lodash.clonedeep "4.5.0"
"@cornerstonejs/core@^0.33.2":
version "0.33.2"
resolved "https://registry.yarnpkg.com/@cornerstonejs/core/-/core-0.33.2.tgz#63aea3eb9787622be0c75052696119a0e58117e6"
integrity sha512-iRHq7WIcZOUxOIMV9KEY7iJjTpcpk7vJPAIZM5tqVvTIbcfaACmxpTlpc2NPqT52o0shRQImIkMFiotUKx0Pug==
"@cornerstonejs/core@^0.36.2":
version "0.36.2"
resolved "https://registry.npmjs.org/@cornerstonejs/core/-/core-0.36.2.tgz#205573bfd75a273fa6bca587662b4dd1f5e46167"
integrity sha512-jJYawOjLGop18O426YxyBepkiaYT/xHMa3mqhToIO5KRxK/UYSGHt0RS8wSHeFR8pNkCAHepcdfhyIVkAln66g==
dependencies:
detect-gpu "^4.0.45"
lodash.clonedeep "4.5.0"
"@cornerstonejs/core@^0.36.0":
version "0.36.0"
resolved "https://registry.yarnpkg.com/@cornerstonejs/core/-/core-0.36.0.tgz#b8e798e04cfceb6106ce4700b2aef14532d814f0"
integrity sha512-vU1wYhezq4x99MT3nuuNS2YVTUn1UkMJ5B9PPSyayQeWxuC0pV0KWBllUAjJA3VR3YDmDUKAfLh9K10u6javYg==
"@cornerstonejs/streaming-image-volume-loader@^0.15.1":
version "0.15.1"
resolved "https://registry.npmjs.org/@cornerstonejs/streaming-image-volume-loader/-/streaming-image-volume-loader-0.15.1.tgz#b9fd0efbebbd232119ef0ae7b63bf8b3498bf539"
integrity sha512-xtBG2RlhjOX/Cd4qGLYGKXjF7oLhRtksmXpPB5nOa1BBBgrGOQHFjNuyh3uhVHg30e5po9oCfomSPHwovhexzw==
dependencies:
detect-gpu "^4.0.45"
lodash.clonedeep "4.5.0"
"@cornerstonejs/streaming-image-volume-loader@^0.14.1":
version "0.14.1"
resolved "https://registry.yarnpkg.com/@cornerstonejs/streaming-image-volume-loader/-/streaming-image-volume-loader-0.14.1.tgz#9830e1cbb65aa0e050336b7f5cb9c81d23e09fc5"
integrity sha512-4m2efDbv00pFQfL/ZjnWjo4RJ3yo4ibv4J/8oro7ZrzhXUJl9L4mwdA1HYCAkS+rZQndZba138AO6b+g4nrmXQ==
dependencies:
"@cornerstonejs/core" "^0.33.1"
"@cornerstonejs/core" "^0.35.1"
cornerstone-wado-image-loader "^4.10.0"
"@cornerstonejs/tools@^0.50.2":
version "0.50.2"
resolved "https://registry.yarnpkg.com/@cornerstonejs/tools/-/tools-0.50.2.tgz#0134b21016ec64290b8f9a43ac1a485654ed86eb"
integrity sha512-MedGsiisDjd2eOewhojwPpWReKM13x1krKIhPNL3hi8rZjV57T8RTpWfztxSjuUpOvapmlJXutrDPuLSUXs01g==
"@cornerstonejs/tools@^0.55.1":
version "0.55.1"
resolved "https://registry.npmjs.org/@cornerstonejs/tools/-/tools-0.55.1.tgz#cde00881c35a43f2d10c634350e46f45e8bf9a7b"
integrity sha512-fYRNqnS9WXWBrkOd++nocKqjlD6p3BvFtPCJeaA8M2bdgEHEHK+KbM999GG5YTmWV88xLW4mjSl+wJvbdWUwEQ==
dependencies:
"@cornerstonejs/core" "^0.33.2"
"@cornerstonejs/core" "^0.36.2"
lodash.clonedeep "4.5.0"
lodash.get "^4.4.2"
@ -8528,9 +8520,9 @@ cornerstone-math@^0.1.9:
integrity sha512-23XSAyP7t70ANvhFyqwvva+zFd1bQ2d5GL7tg9qKE932WmImjA2Y9tiy5n0iTtnf51W/78Png8Lia2o4dCdJaQ==
cornerstone-wado-image-loader@^4.10.0:
version "4.10.0"
resolved "https://registry.npmjs.org/cornerstone-wado-image-loader/-/cornerstone-wado-image-loader-4.10.0.tgz#25c367cfc54a2c92ebbb5c64dba4fe38439112a1"
integrity sha512-XZcgB8DpUxnsTA3vU/zbPtB2uFLL4ght70BPrQHykkX/Jlg/r6Ob7ztX2dEEAAb4ELE/d4icfGuSy10Acg/kyw==
version "4.10.2"
resolved "https://registry.npmjs.org/cornerstone-wado-image-loader/-/cornerstone-wado-image-loader-4.10.2.tgz#139956654324fd2b01fe5b4900d0f4ed8c52633d"
integrity sha512-qj9dThELqYCm3jAZfg9qnUl8d76gngOl55kYJabY5lh/dFeVIxno/hYxy3ydE7RtG2c/TUGXb+EMUl0CJSqKBQ==
dependencies:
"@babel/eslint-parser" "^7.19.1"
"@cornerstonejs/codec-charls" "^1.2.3"