Hanging Protocols: Fixing Lesion Tracker

This commit is contained in:
Eloízio Salgado 2017-02-07 20:09:02 -02:00
parent 20efd80c01
commit f96a37e1bc
5 changed files with 62 additions and 46 deletions

View File

@ -46,11 +46,11 @@ Template.viewer.onCreated(() => {
toggleLesionTrackerTools: OHIF.lesiontracker.toggleLesionTrackerTools, toggleLesionTrackerTools: OHIF.lesiontracker.toggleLesionTrackerTools,
bidirectional: () => { bidirectional: () => {
// Used for hotkeys // Used for hotkeys
toolManager.setActiveTool('bidirectional'); OHIF.viewerbase.toolManager.setActiveTool('bidirectional');
}, },
nonTarget: () => { nonTarget: () => {
// Used for hotkeys // Used for hotkeys
toolManager.setActiveTool('nonTarget'); OHIF.viewerbase.toolManager.setActiveTool('nonTarget');
}, },
// Viewport functions // Viewport functions
toggleCineDialog: viewportUtils.toggleCineDialog, toggleCineDialog: viewportUtils.toggleCineDialog,
@ -81,12 +81,23 @@ Template.viewer.onCreated(() => {
instance.autorun(OHIF.lesiontracker.pixelSpacingAutorunCheck); instance.autorun(OHIF.lesiontracker.pixelSpacingAutorunCheck);
// @TypeSafeStudies // @TypeSafeStudies
// Update the OHIF.viewer.Studies collection with the loaded studies // Clears OHIF.viewer.Studies collection
OHIF.viewer.Studies.removeAll(); OHIF.viewer.Studies.removeAll();
// @TypeSafeStudies
// Clears OHIF.viewer.StudyMetadataList collection
OHIF.viewer.StudyMetadataList.removeAll();
instance.data.studies.forEach(study => { instance.data.studies.forEach(study => {
const studyMetadata = new OHIF.metadata.StudyMetadata(study);
const displaySets = OHIF.viewerbase.sortingManager.getDisplaySets(studyMetadata);
studyMetadata.setDisplaySets(displaySets);
study.selected = true; study.selected = true;
study.displaySets = displaySets;
OHIF.viewer.Studies.insert(study); OHIF.viewer.Studies.insert(study);
OHIF.viewer.StudyMetadataList.insert(studyMetadata);
}); });
instance.data.timepointApi = new OHIF.measurements.TimepointApi(instance.data.currentTimepointId); instance.data.timepointApi = new OHIF.measurements.TimepointApi(instance.data.currentTimepointId);
@ -207,37 +218,12 @@ Template.viewer.onCreated(() => {
}); });
}); });
/**
* Inits OHIF Hanging Protocol's onReady.
* It waits for OHIF Hanging Protocol to be ready to instantiate the ProtocolEngine
* Hanging Protocol will use OHIF LayoutManager to render viewports properly
*/
const initHangingProtocol = () => {
// When Hanging Protocol is ready
HP.ProtocolStore.onReady(() => {
// Gets all StudyMetadata objects: necessary for Hanging Protocol to access study metadata
const studyMetadataList = OHIF.viewer.StudyMetadataList.all();
// Caches Layout Manager: Hanging Protocol uses it for layout management according to current protocol
const layoutManager = OHIF.viewerbase.layoutManager;
// Instantiate StudyMetadataSource: necessary for Hanging Protocol to get study metadata
const studyMetadataSource = new NucleusStudyMetadataSource();
// Creates Protocol Engine object with required arguments
const ProtocolEngine = new HP.ProtocolEngine(layoutManager, studyMetadataList, [], studyMetadataSource);
// Sets up Hanging Protocol engine
HP.setEngine(ProtocolEngine);
});
};
/** /**
* Sets sidebar configuration and active tool based on viewer template instance * Sets sidebar configuration and active tool based on viewer template instance
* @param {Object} instance Template instance for viewer template * @param {Object} instance Template instance for viewer template
*/ */
const setActiveToolAndSidebar = instance => { const setActiveToolAndSidebar = () => {
const instance = Template.instance();
const { studies, currentTimepointId, measurementApi, timepointIds } = instance.data; const { studies, currentTimepointId, measurementApi, timepointIds } = instance.data;
// Default actions for Associated Studies // Default actions for Associated Studies
@ -284,7 +270,7 @@ const setActiveToolAndSidebar = instance => {
} }
// If not set, for associated studies default is target-tool // If not set, for associated studies default is target-tool
toolManager.setActiveTool(activeTool || 'bidirectional'); OHIF.viewerbase.toolManager.setActiveTool(activeTool || 'bidirectional');
} }
// Toggle Measurement Table // Toggle Measurement Table
@ -300,21 +286,37 @@ const setActiveToolAndSidebar = instance => {
} }
}; };
Template.viewer.onRendered(() => { /**
* Inits OHIF Hanging Protocol's onReady.
* It waits for OHIF Hanging Protocol to be ready to instantiate the ProtocolEngine
* Hanging Protocol will use OHIF LayoutManager to render viewports properly
*/
const initHangingProtocol = () => {
// When Hanging Protocol is ready
HP.ProtocolStore.onReady(() => { HP.ProtocolStore.onReady(() => {
const instance = Template.instance();
setActiveToolAndSidebar(instance); setActiveToolAndSidebar();
// updateViewports method from current layout manager will be automatically called by the protocol engine; // Gets all StudyMetadata objects: necessary for Hanging Protocol to access study metadata
const studyMetadataList = OHIF.viewer.StudyMetadataList.all(); const studyMetadataList = OHIF.viewer.StudyMetadataList.all();
// Caches Layout Manager: Hanging Protocol uses it for layout management according to current protocol
const layoutManager = OHIF.viewerbase.layoutManager; const layoutManager = OHIF.viewerbase.layoutManager;
const studyMetadataSource = new OHIFStudyMetadataSource; // Instantiate StudyMetadataSource: necessary for Hanging Protocol to get study metadata
ProtocolEngine = new HP.ProtocolEngine(layoutManager, studyMetadataList, [], studyMetadataSource); const studyMetadataSource = new StudyList.classes.OHIFStudyMetadataSource();
HP.setEngine(ProtocolEngine);
});
// Creates Protocol Engine object with required arguments
const ProtocolEngine = new HP.ProtocolEngine(layoutManager, studyMetadataList, [], studyMetadataSource);
// Sets up Hanging Protocol engine
HP.setEngine(ProtocolEngine);
});
};
Template.viewer.onRendered(function() {
this.autorun(() => { this.autorun(() => {
// To make sure ohif viewerMain is rendered before initializing Hanging Protocols // To make sure ohif viewerMain is rendered before initializing Hanging Protocols
const isOHIFViewerMainRendered = Session.get('OHIFViewerMainRendered'); const isOHIFViewerMainRendered = Session.get('OHIFViewerMainRendered');

View File

@ -100,9 +100,13 @@ Template.viewer.onCreated(() => {
Session.set('activeViewport', ViewerData[contentId].activeViewport || 0); Session.set('activeViewport', ViewerData[contentId].activeViewport || 0);
// @TypeSafeStudies // @TypeSafeStudies
// Update the OHIF.viewer.Studies collection with the loaded studies // Clears OHIF.viewer.Studies collection
OHIF.viewer.Studies.removeAll(); OHIF.viewer.Studies.removeAll();
// @TypeSafeStudies
// Clears OHIF.viewer.StudyMetadataList collection
OHIF.viewer.StudyMetadataList.removeAll();
ViewerData[contentId].studyInstanceUids = []; ViewerData[contentId].studyInstanceUids = [];
instance.data.studies.forEach(study => { instance.data.studies.forEach(study => {
const studyMetadata = new OHIF.metadata.StudyMetadata(study); const studyMetadata = new OHIF.metadata.StudyMetadata(study);

View File

@ -5,7 +5,7 @@ function getDefaultProtocol() {
var oneByOne = new HP.ViewportStructure('grid', { var oneByOne = new HP.ViewportStructure('grid', {
rows: 1, rows: 1,
columns: 1 columns: 2
}); });
var viewport = new HP.Viewport(); var viewport = new HP.Viewport();

View File

@ -27,6 +27,11 @@ Template.measurementTableView.helpers({
hasMeasurements(toolGroupId) { hasMeasurements(toolGroupId) {
const instance = Template.instance(); const instance = Template.instance();
const groups = instance.data.measurementGroups.get(); const groups = instance.data.measurementGroups.get();
if (!groups) {
return false;
}
const group = _.find(groups, item => item.toolGroup.id === toolGroupId); const group = _.find(groups, item => item.toolGroup.id === toolGroupId);
return group && !!group.measurementRows.length; return group && !!group.measurementRows.length;
}, },

View File

@ -11,6 +11,10 @@ import { LayoutManager } from '../../../lib/classes/LayoutManager';
Meteor.startup(() => { Meteor.startup(() => {
window.ResizeViewportManager = window.ResizeViewportManager || new ResizeViewportManager(); window.ResizeViewportManager = window.ResizeViewportManager || new ResizeViewportManager();
// Set initial value for OHIFViewerMainRendered
// session variable. This can used in viewer main template
Session.set('OHIFViewerMainRendered', false);
}); });
Template.viewerMain.onCreated(() => { Template.viewerMain.onCreated(() => {
@ -36,8 +40,7 @@ Template.viewerMain.onRendered(() => {
// Enable hotkeys // Enable hotkeys
hotkeyUtils.enableHotkeys(); hotkeyUtils.enableHotkeys();
Session.set('OHIFViewerMainRendered', {}); Session.set('OHIFViewerMainRendered', Random.id());
}); });
Template.viewerMain.onDestroyed(() => { Template.viewerMain.onDestroyed(() => {
@ -54,4 +57,6 @@ Template.viewerMain.onDestroyed(() => {
delete OHIF.viewerbase.layoutManager; delete OHIF.viewerbase.layoutManager;
delete ProtocolEngine; delete ProtocolEngine;
Session.set('OHIFViewerMainRendered', false);
}); });