[WIP] Moving new Hanging-Protocol bootstrap from Nucleus to OHIF Viewers

This commit is contained in:
Emanuel F. Oliveira authored and Eloízio Salgado committed 2017-03-02 10:15:09 -03:00
1 parent a159c105b0
commit 7fa581e52b
12 files changed
+421 -116

No files matched your search

@@ -28,85 +28,93 @@ Template.viewerMain.onCreated(() => {
Template.viewerMain.onRendered(() => {
const instance = Template.instance();
const { studies } = instance.data;
const parentElement = instance.$('#layoutManagerTarget').get(0);
HP.ProtocolStore.onReady(() => {
const { studies, currentTimepointId, measurementApi, timepointIds } = instance.data;
const parentElement = instance.$('#layoutManagerTarget').get(0);
OHIF.viewerbase.layoutManager = new LayoutManager(parentElement, studies);
OHIF.viewerbase.layoutManager = new LayoutManager(parentElement, studies);
// @TODO: move this logic to the viewers to break dependency of ohif-hanging-protocols package and avoid circurlar dependencies
// HP.ProtocolStore.onReady(() => {
// const { studies, currentTimepointId, measurementApi, timepointIds } = instance.data;
// Default actions for Associated Studies
if(currentTimepointId) {
// Follow-up studies: same as the first measurement in the table
// Baseline studies: target-tool
if(studies[0]) {
let activeTool;
// In follow-ups, get the baseline timepointId
const timepointId = timepointIds.find(id => id !== currentTimepointId);
// // Default actions for Associated Studies
// if(currentTimepointId) {
// // Follow-up studies: same as the first measurement in the table
// // Baseline studies: target-tool
// if(studies[0]) {
// let activeTool;
// // In follow-ups, get the baseline timepointId
// const timepointId = timepointIds.find(id => id !== currentTimepointId);
// Follow-up studies
if(studies[0].timepointType === 'followup' && timepointId) {
const measurementTools = OHIF.measurements.MeasurementApi.getConfiguration().measurementTools;
// // Follow-up studies
// if(studies[0].timepointType === 'followup' && timepointId) {
// const measurementTools = OHIF.measurements.MeasurementApi.getConfiguration().measurementTools;
// Create list of measurement tools
const measurementTypes = measurementTools.map(
tool => {
const { id, cornerstoneToolType } = tool;
return {
id,
cornerstoneToolType
}
}
);
// // Create list of measurement tools
// const measurementTypes = measurementTools.map(
// tool => {
// const { id, cornerstoneToolType } = tool;
// return {
// id,
// cornerstoneToolType
// }
// }
// );
// Iterate over each measurment tool to find the first baseline
// measurment. If so, stops the loop and prevent fetching from all
// collections
measurementTypes.every(({id, cornerstoneToolType}) => {
// Get measurement
if(measurementApi[id]) {
const measurement = measurementApi[id].findOne({ timepointId });
// // Iterate over each measurment tool to find the first baseline
// // measurment. If so, stops the loop and prevent fetching from all
// // collections
// measurementTypes.every(({id, cornerstoneToolType}) => {
// // Get measurement
// if(measurementApi[id]) {
// const measurement = measurementApi[id].findOne({ timepointId });
// Found a measurement, save tool and stop loop
if(measurement) {
activeTool = cornerstoneToolType;
// // Found a measurement, save tool and stop loop
// if(measurement) {
// activeTool = cornerstoneToolType;
return false;
}
}
return true;
});
}
// return false;
// }
// }
// return true;
// });
// }
// If not set, for associated studies default is target-tool
toolManager.setActiveTool(activeTool || 'bidirectional');
}
// // If not set, for associated studies default is target-tool
// toolManager.setActiveTool(activeTool || 'bidirectional');
// }
// Toggle Measurement Table
if(instance.data.state) {
instance.data.state.set('rightSidebar', 'measurements');
}
}
// Hide as default for single study
else {
if(instance.data.state) {
instance.data.state.set('rightSidebar', null);
}
}
// // Toggle Measurement Table
// if(instance.data.state) {
// instance.data.state.set('rightSidebar', 'measurements');
// }
// }
// // Hide as default for single study
// else {
// if(instance.data.state) {
// instance.data.state.set('rightSidebar', null);
// }
// }
if (OHIF.viewer.isProtocolEngineDisabled === true) {
OHIF.viewerbase.layoutManager.updateViewports();
} else {
// updateViewports method from current layout manager will be automatically called by the protocol engine;
ProtocolEngine = new HP.ProtocolEngine(OHIF.viewerbase.layoutManager, studies);
HP.setEngine(ProtocolEngine);
}
// if (OHIF.viewer.isProtocolEngineDisabled === true) {
// OHIF.viewerbase.layoutManager.updateViewports();
// } else {
// // updateViewports method from current layout manager will be automatically called by the protocol engine;
// const studyMetadataList = OHIF.viewer.StudyMetadataList.all();
// const layoutManager = OHIF.viewerbase.layoutManager;
// const studyMetadataSource = new NucleusStudyMetadataSource;
// ProtocolEngine = new HP.ProtocolEngine(layoutManager, studyMetadataList, [], studyMetadataSource);
// HP.setEngine(ProtocolEngine);
// }
// Enable hotkeys
hotkeyUtils.enableHotkeys();
// Session.set('ViewerMainReady', Random.id());
// });
Session.set('ViewerMainReady', Random.id());
});
// Enable hotkeys
hotkeyUtils.enableHotkeys();
Session.set('ViewerMainRendered', Random.id());
});
Template.viewerMain.onDestroyed(() => {