fix(toolbox): Preserve user-specified tool state and streamline command execution (#4063)
This commit is contained in:
1 parent
4784638717
commit
f1a736d193
34 files changed
+332
-181
No files matched your search
@@ -532,6 +532,11 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
|
||||
cameraProps: unknown
|
||||
): string {
|
||||
const viewportInfo = this.getViewportInfo(activeViewportId);
|
||||
|
||||
if (viewportInfo.getViewportType() === csEnums.ViewportType.VOLUME_3D) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { referencedImageId } = cameraProps;
|
||||
if (viewportInfo?.contains(displaySetInstanceUID, referencedImageId)) {
|
||||
return activeViewportId;
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { Types, Enums } from '@cornerstonejs/core';
|
||||
import {
|
||||
Types,
|
||||
Enums,
|
||||
getEnabledElementByViewportId,
|
||||
VolumeViewport,
|
||||
utilities,
|
||||
} from '@cornerstonejs/core';
|
||||
import { Types as CoreTypes } from '@ohif/core';
|
||||
import { StackViewportData, VolumeViewportData } from '../../types/CornerstoneCacheService';
|
||||
import getCornerstoneBlendMode from '../../utils/getCornerstoneBlendMode';
|
||||
@@ -89,13 +95,30 @@ const DEFAULT_TOOLGROUP_ID = 'default';
|
||||
|
||||
// Return true if the data contains the given display set UID OR the imageId
|
||||
// if it is a composite object.
|
||||
const dataContains = (data, displaySetUID: string, imageId?: string): boolean => {
|
||||
if (data.displaySetInstanceUID === displaySetUID) {
|
||||
return true;
|
||||
}
|
||||
const dataContains = ({ data, displaySetUID, imageId, viewport }): boolean => {
|
||||
if (imageId && data.isCompositeStack && data.imageIds) {
|
||||
return !!data.imageIds.find(dataId => dataId === imageId);
|
||||
}
|
||||
|
||||
if (imageId && (data.volumeId || viewport instanceof VolumeViewport)) {
|
||||
const isAcquisition = !!viewport.getCurrentImageId();
|
||||
|
||||
if (!isAcquisition) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const imageURI = utilities.imageIdToURI(imageId);
|
||||
const hasImageId = viewport.hasImageURI(imageURI);
|
||||
|
||||
if (hasImageId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (data.displaySetInstanceUID === displaySetUID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
@@ -122,10 +145,20 @@ class ViewportInfo {
|
||||
return false;
|
||||
}
|
||||
|
||||
const { viewport } = getEnabledElementByViewportId(this.viewportId) || {};
|
||||
|
||||
if (this.viewportData.data.length) {
|
||||
return !!this.viewportData.data.find(data => dataContains(data, displaySetUID, imageId));
|
||||
return !!this.viewportData.data.find(data =>
|
||||
dataContains({ data, displaySetUID, imageId, viewport })
|
||||
);
|
||||
}
|
||||
return dataContains(this.viewportData.data, displaySetUID, imageId);
|
||||
|
||||
return dataContains({
|
||||
data: this.viewportData.data,
|
||||
displaySetUID,
|
||||
imageId,
|
||||
viewport,
|
||||
});
|
||||
}
|
||||
|
||||
public destroy = (): void => {
|
||||
|
||||
Reference in new issue
Block a user