Adding metadata support for rule entry dialog

This commit is contained in:
Eloízio Salgado committed 2017-03-02 10:18:11 -03:00
1 parent bec8f21c0a
commit 2333276e96
5 files changed
+163 -54

No files matched your search

@@ -160,6 +160,22 @@ export class SeriesMetadata extends Metadata {
return this._instances.indexOf(instance);
}
/**
* Search the associated instances using the supplied callback as criteria. The callback is passed
* two arguments: instance (a InstanceMetadata instance) and index (the integer
* index of the instance within its series)
* @param {function} callback The callback function which will be invoked for each instance.
* @returns {InstanceMetadata|undefined} If an instance is found based on callback criteria it
* returns a InstanceMetadata. "undefined" is returned otherwise
*/
findInstance(callback) {
if (Metadata.isValidCallback(callback)) {
return this._instances.find((instance, index) => {
return callback.call(null, instance, index);
});
}
}
/**
* Compares the current series with another one.
* @param {SeriesMetadata} series An instance of the SeriesMetadata class.
@@ -338,4 +338,65 @@ export class StudyMetadata extends Metadata {
return instance;
}
/**
* Search the associated series to find an specific instance using the supplied callback as criteria.
* The callback is passed two arguments: instance (a InstanceMetadata instance) and index (the integer
* index of the instance within the current series)
* @param {function} callback The callback function which will be invoked for each instance instance.
* @returns {Object} Result object containing series (SeriesMetadata) and instance (InstanceMetadata)
* objects or an empty object if not found.
*/
findSeriesAndInstanceByInstance(callback) {
let result;
if (Metadata.isValidCallback(callback)) {
let instance;
const series = this._series.find(series => {
instance = series.findInstance(callback);
return instance instanceof InstanceMetadata;
});
// No series found
if (series instanceof SeriesMetadata) {
result = {
series,
instance
};
}
}
return result || {};
}
/**
* Find series by instance using the supplied callback as criteria. The callback is passed
* two arguments: instance (a InstanceMetadata instance) and index (the integer index of
* the instance within its series)
* @param {function} callback The callback function which will be invoked for each instance.
* @returns {SeriesMetadata|undefined} If a series is found based on callback criteria it
* returns a SeriesMetadata. "undefined" is returned otherwise
*/
findSeriesByInstance(callback) {
const result = this.findSeriesAndInstanceByInstance(callback);
return result.series;
}
/**
* Find an instance using the supplied callback as criteria. The callback is passed
* two arguments: instance (a InstanceMetadata instance) and index (the integer index of
* the instance within its series)
* @param {function} callback The callback function which will be invoked for each instance.
* @returns {InstanceMetadata|undefined} If an instance is found based on callback criteria it
* returns a InstanceMetadata. "undefined" is returned otherwise
*/
findInstance(callback) {
const result = this.findSeriesAndInstanceByInstance(callback);
return result.instance;
}
}
@@ -7,11 +7,46 @@ import { OHIF } from 'meteor/ohif:core';
import { updateOrientationMarkers } from './updateOrientationMarkers';
import { getInstanceClassDefaultViewport } from './instanceClassSpecificViewport';
/**
* Get a cornerstone enabledElement for a DOM Element
* @param {DOMElement} element Element to get the enabledElement from Cornerstone
* @return {Object} Cornerstone's enabledElement object for the given
* element or undefined if the element is not enabled
*/
const getEnabledElement = element => {
let enabledElement;
try {
enabledElement = cornerstone.getEnabledElement(element);
} catch(error) {
OHIF.log.warn(error);
}
return enabledElement;
};
/**
* Get the active viewport element. It uses activeViewport Session Variable
* @return {DOMElement} DOMElement of the current active viewport
*/
const getActiveViewportElement = () => {
const viewportIndex = Session.get('activeViewport') || 0;
return $('.imageViewerViewport').get(viewportIndex);
};
/**
* Get a cornerstone enabledElement for the Active Viewport Element
* @return {Object} Cornerstone's enabledElement object for the active
* viewport element or undefined if the element
* is not enabled
*/
const getEnabledElementForActiveElement = () => {
const activeViewportElement = getActiveViewportElement();
const enabledElement = getEnabledElement(activeViewportElement);
return enabledElement;
};
const zoomIn = () => {
const element = getActiveViewportElement();
if (!element) {
@@ -99,8 +134,7 @@ const flipH = () => {
};
const resetViewport = () => {
const element = getActiveViewportElement();
const enabledElement = cornerstone.getEnabledElement(element);
const enabledElement = getEnabledElementForActiveElement();
if (enabledElement.fitToWindow === false) {
const imageId = enabledElement.image.imageId;
const instance = cornerstoneTools.metaData.get('instance', imageId);
@@ -272,6 +306,8 @@ $(window).on('CornerstoneToolsClipStopped', () => Session.set('UpdateCINE', Rand
*/
const viewportUtils = {
getEnabledElementForActiveElement,
getEnabledElement,
getActiveViewportElement,
zoomIn,
zoomOut,