fix(typescript): rename services to fix typescript (#3165)

* fix: Rename services to lower camel case, hp, measure

* fix: Rename DisplaySetService instances to displaySetService

* fix: Rename CornerstoneViewportService to lower camel case

* fix: Added lower case segmentationService rename

* rename other services (#3166)

* rename uiDialogService

* rename toolGroupService

* rename uiNotificationService

* rename viewportGridService

* rename syncGroupService

* rename CornerstoneCacheService

* Fix a syntax error in hotkeys

* Fix a couple of rename issues that were missed

---------

Co-authored-by: Alireza <ar.sedghi@gmail.com>
This commit is contained in:
Bill WallaceandAlireza authored and GitHub committed 2023-02-10 16:46:09 -05:00
1 parent a97fb2fc9a
commit 8af0362d12
97 files changed
+934 -908

No files matched your search

@@ -1,5 +1,5 @@
import { ServicesManager } from '@ohif/core';
import { cache as cs3DCache, Enums, volumeLoader } from '@cornerstonejs/core';
import { utils } from '@ohif/core';
import getCornerstoneViewportType from '../../utils/getCornerstoneViewportType';
import {
@@ -10,6 +10,16 @@ import {
const VOLUME_LOADER_SCHEME = 'cornerstoneStreamingImageVolume';
class CornerstoneCacheService {
static REGISTRATION = (serviceManager: ServicesManager) => {
return {
name: 'cornerstoneCacheService',
altName: 'CornerstoneCacheService',
create: ({ configuration = {} }) => {
return new CornerstoneCacheService(serviceManager);
},
};
};
stackImageIds: Map<string, string[]> = new Map();
volumeImageIds: Map<string, string[]> = new Map();
@@ -69,7 +79,7 @@ class CornerstoneCacheService {
viewportData: VolumeViewportData,
invalidatedDisplaySetInstanceUID: string,
dataSource,
DisplaySetService
displaySetService
) {
if (viewportData.viewportType === Enums.ViewportType.STACK) {
throw new Error('Invalidation of StackViewport is not supported yet');
@@ -85,7 +95,7 @@ class CornerstoneCacheService {
}
const displaySets = viewportData.data.map(({ displaySetInstanceUID }) =>
DisplaySetService.getDisplaySetByUID(displaySetInstanceUID)
displaySetService.getDisplaySetByUID(displaySetInstanceUID)
);
const newViewportData = await this._getVolumeViewportData(
@@ -203,7 +213,7 @@ class CornerstoneCacheService {
}
private _shouldRenderSegmentation(displaySets) {
const { SegmentationService } = this.servicesManager.services;
const { segmentationService } = this.servicesManager.services;
const viewportDisplaySetInstanceUIDs = displaySets.map(
({ displaySetInstanceUID }) => displaySetInstanceUID
@@ -211,12 +221,12 @@ class CornerstoneCacheService {
// check inside segmentations if any of them are referencing the displaySets
// that are about to be displayed
const segmentations = SegmentationService.getSegmentations();
const segmentations = segmentationService.getSegmentations();
for (const segmentation of segmentations) {
const segDisplaySetInstanceUID = segmentation.displaySetInstanceUID;
const shouldDisplaySeg = SegmentationService.shouldRenderSegmentation(
const shouldDisplaySeg = segmentationService.shouldRenderSegmentation(
viewportDisplaySetInstanceUIDs,
segDisplaySetInstanceUID
);
@@ -1,10 +1,3 @@
import CornerstoneCacheService from './CornerstoneCacheService';
export default function ExtendedCornerstoneCacheService(serviceManager) {
return {
name: 'CornerstoneCacheService',
create: ({ configuration = {} }) => {
return new CornerstoneCacheService(serviceManager);
},
};
}
export default CornerstoneCacheService;
@@ -738,7 +738,7 @@ class SegmentationService {
highlightHideOthers = false,
highlightFunctionType: 'ease-in-out' // todo: make animation functions configurable from outside
): void {
const { ToolGroupService } = this.servicesManager.services;
const { toolGroupService } = this.servicesManager.services;
const center = this._getSegmentCenter(segmentationId, segmentIndex);
const { world } = center;
@@ -751,10 +751,10 @@ class SegmentationService {
if (Array.isArray(toolGroupId)) {
toolGroupId.forEach(toolGroup => {
toolGroups.push(ToolGroupService.getToolGroup(toolGroup));
toolGroups.push(toolGroupService.getToolGroup(toolGroup));
});
} else {
toolGroups.push(ToolGroupService.getToolGroup(toolGroupId));
toolGroups.push(toolGroupService.getToolGroup(toolGroupId));
}
toolGroups.forEach(toolGroup => {
@@ -1240,9 +1240,9 @@ class SegmentationService {
}
// if (brushSize !== undefined) {
// const { ToolGroupService } = this.servicesManager.services;
// const { toolGroupService } = this.servicesManager.services;
// const toolGroupIds = ToolGroupService.getToolGroupIds();
// const toolGroupIds = toolGroupService.getToolGroupIds();
// toolGroupIds.forEach(toolGroupId => {
// cstUtils.segmentation.setBrushSizeForToolGroup(toolGroupId, brushSize);
@@ -1250,9 +1250,9 @@ class SegmentationService {
// }
// if (brushThresholdGate !== undefined) {
// const { ToolGroupService } = this.servicesManager.services;
// const { toolGroupService } = this.servicesManager.services;
// const toolGroupIds = ToolGroupService.getFirstToolGroupIds();
// const toolGroupIds = toolGroupService.getFirstToolGroupIds();
// toolGroupIds.forEach(toolGroupId => {
// cstUtils.segmentation.setBrushThresholdForToolGroup(
@@ -1324,11 +1324,11 @@ class SegmentationService {
return false;
}
const { DisplaySetService } = this.servicesManager.services;
const { displaySetService } = this.servicesManager.services;
let shouldDisplaySeg = false;
const segDisplaySet = DisplaySetService.getDisplaySetByUID(
const segDisplaySet = displaySetService.getDisplaySetByUID(
segDisplaySetInstanceUID
);
@@ -1337,7 +1337,7 @@ class SegmentationService {
viewportDisplaySetInstanceUIDs.forEach(displaySetInstanceUID => {
// check if the displaySet is sharing the same frameOfReferenceUID
// with the new segmentation
const displaySet = DisplaySetService.getDisplaySetByUID(
const displaySet = displaySetService.getDisplaySetByUID(
displaySetInstanceUID
);
@@ -1710,7 +1710,7 @@ class SegmentationService {
}
private _setLabelmapConfigValue = (property, value) => {
const { CornerstoneViewportService } = this.servicesManager.services;
const { cornerstoneViewportService } = this.servicesManager.services;
const config = cstSegmentation.config.getGlobalConfig();
@@ -1719,8 +1719,8 @@ class SegmentationService {
// Todo: add non global (representation specific config as well)
cstSegmentation.config.setGlobalConfig(config);
const renderingEngine = CornerstoneViewportService.getRenderingEngine();
const viewportIds = CornerstoneViewportService.getViewportIds();
const renderingEngine = cornerstoneViewportService.getRenderingEngine();
const viewportIds = cornerstoneViewportService.getViewportIds();
renderingEngine.renderViewports(viewportIds);
};
@@ -1953,8 +1953,8 @@ class SegmentationService {
}
private _getFirstToolGroupId = () => {
const { ToolGroupService } = this.servicesManager.services;
const toolGroupIds = ToolGroupService.getToolGroupIds();
const { toolGroupService } = this.servicesManager.services;
const toolGroupIds = toolGroupService.getToolGroupIds();
return toolGroupIds[0];
};
@@ -2,7 +2,8 @@ import SegmentationService from './SegmentationService';
export default function ExtendedSegmentationService(servicesManager) {
return {
name: 'SegmentationService',
name: 'segmentationService',
altName: 'SegmentationService',
create: ({ configuration = {} }) => {
return new SegmentationService({ servicesManager });
},
@@ -2,7 +2,8 @@ import SyncGroupService from './SyncGroupService';
export default function ExtendedSyncGroupService(serviceManager) {
return {
name: 'SyncGroupService',
altName: 'SyncGroupService',
name: 'syncGroupService',
create: ({ configuration = {} }) => {
return new SyncGroupService(serviceManager);
},
@@ -20,6 +20,16 @@ type Tools = {
};
export default class ToolGroupService {
public static REGISTRATION = serviceManager => {
return {
name: 'toolGroupService',
altName: 'ToolGroupService',
create: ({ configuration = {} }) => {
return new ToolGroupService(serviceManager);
},
};
};
serviceManager: any;
private toolGroupIds: Set<string> = new Set();
/**
@@ -29,8 +39,8 @@ export default class ToolGroupService {
EVENTS: { [key: string]: string };
constructor(serviceManager) {
const { CornerstoneViewportService } = serviceManager.services;
this.CornerstoneViewportService = CornerstoneViewportService;
const { cornerstoneViewportService } = serviceManager.services;
this.cornerstoneViewportService = cornerstoneViewportService;
this.listeners = {};
this.EVENTS = EVENTS;
Object.assign(this, pubSubServiceInterface);
@@ -51,7 +61,7 @@ export default class ToolGroupService {
}
public getToolGroupForViewport(viewportId: string): Types.IToolGroup | void {
const renderingEngine = this.CornerstoneViewportService.getRenderingEngine();
const renderingEngine = this.cornerstoneViewportService.getRenderingEngine();
return ToolGroupManager.getToolGroupForViewport(
viewportId,
renderingEngine.id
@@ -1,10 +1,3 @@
import ToolGroupService from './ToolGroupService';
export default function ExtendedToolGroupService(serviceManager) {
return {
name: 'ToolGroupService',
create: ({ configuration = {} }) => {
return new ToolGroupService(serviceManager);
},
};
}
export default ToolGroupService;
@@ -412,7 +412,7 @@ class CornerstoneViewportService implements IViewportService {
// (This call may or may not create sub-requests for series metadata)
const volumeInputArray = [];
const displaySetOptionsArray = viewportInfo.getDisplaySetOptions();
const { HangingProtocolService } = this.servicesManager.services;
const { hangingProtocolService } = this.servicesManager.services;
const volumeToLoad = [];
const displaySetInstanceUIDs = [];
@@ -449,11 +449,11 @@ class CornerstoneViewportService implements IViewportService {
this.viewportsDisplaySets.set(viewport.id, displaySetInstanceUIDs);
if (
HangingProtocolService.hasCustomImageLoadStrategy() &&
!HangingProtocolService.customImageLoadPerformed
hangingProtocolService.hasCustomImageLoadStrategy() &&
!hangingProtocolService.customImageLoadPerformed
) {
// delegate the volume loading to the hanging protocol service if it has a custom image load strategy
return HangingProtocolService.runImageLoadStrategy({
return hangingProtocolService.runImageLoadStrategy({
viewportId: viewport.id,
volumeInputArray,
});
@@ -469,9 +469,9 @@ class CornerstoneViewportService implements IViewportService {
public async setVolumesForViewport(viewport, volumeInputArray) {
const {
DisplaySetService,
SegmentationService,
ToolGroupService,
displaySetService,
segmentationService,
toolGroupService,
} = this.servicesManager.services;
await viewport.setVolumes(volumeInputArray);
@@ -480,7 +480,7 @@ class CornerstoneViewportService implements IViewportService {
const displaySetInstanceUIDs = this.viewportsDisplaySets.get(viewport.id);
const segDisplaySet = displaySetInstanceUIDs
.map(DisplaySetService.getDisplaySetByUID)
.map(displaySetService.getDisplaySetByUID)
.find(displaySet => displaySet && displaySet.Modality === 'SEG');
if (segDisplaySet) {
@@ -488,18 +488,18 @@ class CornerstoneViewportService implements IViewportService {
const referencedVolume = cache.getVolume(referencedVolumeId);
const segmentationId = segDisplaySet.displaySetInstanceUID;
const toolGroup = ToolGroupService.getToolGroupForViewport(viewport.id);
const toolGroup = toolGroupService.getToolGroupForViewport(viewport.id);
if (referencedVolume) {
SegmentationService.addSegmentationRepresentationToToolGroup(
segmentationService.addSegmentationRepresentationToToolGroup(
toolGroup.id,
segmentationId
);
}
} else {
const toolGroup = ToolGroupService.getToolGroupForViewport(viewport.id);
const toolGroup = toolGroupService.getToolGroupForViewport(viewport.id);
const toolGroupSegmentationRepresentations =
SegmentationService.getSegmentationRepresentationsForToolGroup(
segmentationService.getSegmentationRepresentationsForToolGroup(
toolGroup.id
) || [];
@@ -508,7 +508,7 @@ class CornerstoneViewportService implements IViewportService {
// and we can look into hydrated segmentations to check if any of them are
// associated with the primary displaySet
// get segmentations only returns the hydrated segmentations
const segmentations = SegmentationService.getSegmentations();
const segmentations = segmentationService.getSegmentations();
for (const segmentation of segmentations) {
// if there is already a segmentation representation for this segmentation
@@ -543,11 +543,11 @@ class CornerstoneViewportService implements IViewportService {
}
if (shouldDisplaySeg) {
const toolGroup = ToolGroupService.getToolGroupForViewport(
const toolGroup = toolGroupService.getToolGroupForViewport(
viewport.id
);
SegmentationService.addSegmentationRepresentationToToolGroup(
segmentationService.addSegmentationRepresentationToToolGroup(
toolGroup.id,
segmentation.id
);
@@ -557,7 +557,7 @@ class CornerstoneViewportService implements IViewportService {
const viewportInfo = this.getViewportInfo(viewport.id);
const toolGroup = ToolGroupService.getToolGroupForViewport(viewport.id);
const toolGroup = toolGroupService.getToolGroupForViewport(viewport.id);
csToolsUtils.segmentation.triggerSegmentationRender(toolGroup.id);
const initialImageOptions = viewportInfo.getInitialImageOptions();
@@ -733,8 +733,8 @@ class CornerstoneViewportService implements IViewportService {
}
_getFrameOfReferenceUID(displaySetInstanceUID) {
const { DisplaySetService } = this.servicesManager.services;
const displaySet = DisplaySetService.getDisplaySetByUID(
const { displaySetService } = this.servicesManager.services;
const displaySet = displaySetService.getDisplaySetByUID(
displaySetInstanceUID
);
@@ -12,7 +12,7 @@ import {
*/
export interface IViewportService {
servicesManager: unknown;
HangingProtocolService: unknown;
hangingProtocolService: unknown;
renderingEngine: unknown;
viewportGridResizeObserver: unknown;
viewportsInfo: unknown;
@@ -7,7 +7,7 @@ import { SyncGroup } from '../SyncGroupService/SyncGroupService';
import {
StackViewportData,
VolumeViewportData,
} from './CornerstoneCacheService';
} from '../../types/CornerstoneCacheService';
export type InitialImageOptions = {
index?: number;