Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | 34x 34x 34x 34x 46x 46x 46x 12x 12x 12x 12x 12x 12x 12x 159x 1449x 124x 34x | import { PubSubService } from '@ohif/core'; const EVENTS = { TRACKED_SERIES_CHANGED: 'event::trackedmeasurements:trackedserieschanged', SERIES_ADDED: 'event::trackedmeasurements:seriesadded', SERIES_REMOVED: 'event::trackedmeasurements:seriesremoved', TRACKING_ENABLED: 'event::trackedmeasurements:trackingenabled', TRACKING_DISABLED: 'event::trackedmeasurements:trackingdisabled', }; /** * Service class for accessing tracked measurements data. * This service provides a robust way to access tracked series information * from anywhere in the application, including outside of React components. */ export class TrackedMeasurementsService extends PubSubService { public static readonly REGISTRATION = { name: 'trackedMeasurementsService', altName: 'TrackedMeasurementsService', create: ({ configuration = {} }) => { return new TrackedMeasurementsService(); }, }; private _trackedSeries: string[] = []; constructor() { super(EVENTS); } /** * Updates the tracked series and notifies subscribers * @param trackedSeries Array of series UIDs being tracked */ public updateTrackedSeries(trackedSeries: string[]): void { Iif (!trackedSeries) { trackedSeries = []; } const hasChanged = this._trackedSeries.length !== trackedSeries.length || this._trackedSeries.some((seriesUID, index) => seriesUID !== trackedSeries[index]); if (hasChanged) { const oldSeries = [...this._trackedSeries]; this._trackedSeries = [...trackedSeries]; const wasEmpty = oldSeries.length === 0; const isEmpty = trackedSeries.length === 0; if (wasEmpty && !isEmpty) { this._broadcastEvent(EVENTS.TRACKING_ENABLED, { trackedSeries: this.getTrackedSeries(), }); } else IEif (!wasEmpty && isEmpty) { this._broadcastEvent(EVENTS.TRACKING_DISABLED, { trackedSeries: this.getTrackedSeries(), }); } this._broadcastEvent(EVENTS.TRACKED_SERIES_CHANGED, { trackedSeries: this.getTrackedSeries(), }); } } /** * Adds a single series to tracking * @param seriesInstanceUID Series instance UID to add to tracking */ public addTrackedSeries(seriesInstanceUID: string): void { Iif (!seriesInstanceUID || this.isSeriesTracked(seriesInstanceUID)) { return; } const wasEmpty = this._trackedSeries.length === 0; this._trackedSeries = [...this._trackedSeries, seriesInstanceUID]; this._broadcastEvent(EVENTS.SERIES_ADDED, { seriesInstanceUID, trackedSeries: this.getTrackedSeries(), }); Iif (wasEmpty) { this._broadcastEvent(EVENTS.TRACKING_ENABLED, { trackedSeries: this.getTrackedSeries(), }); } this._broadcastEvent(EVENTS.TRACKED_SERIES_CHANGED, { trackedSeries: this.getTrackedSeries(), }); } /** * Removes a single series from tracking * @param seriesInstanceUID Series instance UID to remove from tracking */ public removeTrackedSeries(seriesInstanceUID: string): void { Iif (!seriesInstanceUID || !this.isSeriesTracked(seriesInstanceUID)) { return; } this._trackedSeries = this._trackedSeries.filter(uid => uid !== seriesInstanceUID); this._broadcastEvent(EVENTS.SERIES_REMOVED, { seriesInstanceUID, trackedSeries: this.getTrackedSeries(), }); Iif (this._trackedSeries.length === 0) { this._broadcastEvent(EVENTS.TRACKING_DISABLED, { trackedSeries: this.getTrackedSeries(), }); } this._broadcastEvent(EVENTS.TRACKED_SERIES_CHANGED, { trackedSeries: this.getTrackedSeries(), }); } /** * Retrieves the currently tracked series * @returns Array of series UIDs being tracked */ public getTrackedSeries(): string[] { return [...this._trackedSeries]; } /** * Checks if a specific series is being tracked * @param seriesInstanceUID Series instance UID to check * @returns boolean indicating if series is tracked */ public isSeriesTracked(seriesInstanceUID: string): boolean { return this._trackedSeries.includes(seriesInstanceUID); } /** * Resets the service state */ public reset(): void { const wasTracking = this._trackedSeries.length > 0; this._trackedSeries = []; Iif (wasTracking) { this._broadcastEvent(EVENTS.TRACKING_DISABLED, { trackedSeries: [], }); this._broadcastEvent(EVENTS.TRACKED_SERIES_CHANGED, { trackedSeries: [], }); } super.reset(); } /** * Checks if any series are being tracked * @returns boolean indicating if tracking is active */ public isTrackingEnabled(): boolean { return this._trackedSeries.length > 0; } } export default TrackedMeasurementsService; |