Fixing issues with viewports linking
This commit is contained in:
parent
66c8db697f
commit
335c3526cc
@ -3,8 +3,14 @@ import { _ } from 'meteor/underscore';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
Meteor.startup(() => {
|
||||
const { toolManager } = OHIF.viewerbase;
|
||||
const contextName = 'viewer';
|
||||
|
||||
// Enable the custom tools
|
||||
const customTools = [{
|
||||
id: 'bidirectional',
|
||||
name: 'Target'
|
||||
}, {
|
||||
id: 'nonTarget',
|
||||
name: 'Non-Target'
|
||||
}, {
|
||||
@ -14,12 +20,25 @@ Meteor.startup(() => {
|
||||
id: 'targetUN',
|
||||
name: 'UN Target'
|
||||
}];
|
||||
|
||||
customTools.forEach(tool => {
|
||||
_.defaults(OHIF.hotkeys.defaults.viewer, { [tool.id]: '' });
|
||||
OHIF.commands.register('viewer', tool.id, {
|
||||
OHIF.commands.register(contextName, tool.id, {
|
||||
name: tool.name,
|
||||
action: () => OHIF.viewerbase.toolManager.setActiveTool(tool.id)
|
||||
action: tool.action || (() => toolManager.setActiveTool(tool.id))
|
||||
});
|
||||
});
|
||||
|
||||
// Enable the custom commands
|
||||
const customCommands = [{
|
||||
id: 'linkStackScroll',
|
||||
name: 'Link',
|
||||
action: OHIF.viewerbase.viewportUtils.linkStackScroll
|
||||
}];
|
||||
customCommands.forEach(command => {
|
||||
_.defaults(OHIF.hotkeys.defaults.viewer, { [command.id]: '' });
|
||||
OHIF.commands.register(contextName, command.id, {
|
||||
name: command.name,
|
||||
action: command.action || (() => toolManager.setActiveTool(command.id))
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -117,7 +117,8 @@ Template.dialogStudyAssociation.onCreated(() => {
|
||||
studyInstanceUids: studyInstanceUids,
|
||||
patientId: relatedStudies[0].patientId,
|
||||
earliestDate: studyDates[0],
|
||||
latestDate: studyDates[studyDates.length - 1]
|
||||
latestDate: studyDates[studyDates.length - 1],
|
||||
isLocked: false
|
||||
};
|
||||
|
||||
// Insert this timepoint into the Timepoints Collection
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { $ } from 'meteor/jquery';
|
||||
import { _ } from 'meteor/underscore';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import 'meteor/ohif:viewerbase';
|
||||
|
||||
@ -63,7 +64,15 @@ function renderIntoViewport(viewportIndex, studyInstanceUid, seriesInstanceUid,
|
||||
}
|
||||
|
||||
function syncViewports(viewportsIndexes) {
|
||||
OHIF.viewer.stackImagePositionOffsetSynchronizer.activateByViewportIndexes(viewportsIndexes);
|
||||
const synchronizer = OHIF.viewer.stackImagePositionOffsetSynchronizer;
|
||||
const linkableViewports = synchronizer.getLinkableViewports();
|
||||
if (linkableViewports.length) {
|
||||
const linkableViewportsIndexes = _.pluck(linkableViewports, 'index');
|
||||
const indexes = _.intersection(linkableViewportsIndexes, viewportsIndexes);
|
||||
if (indexes.length) {
|
||||
OHIF.viewer.stackImagePositionOffsetSynchronizer.activateByViewportIndexes(indexes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -68,7 +68,7 @@ export class StackImagePositionOffsetSynchronizer {
|
||||
this.synchronizer.add(viewport.element);
|
||||
this.syncedViewports.push(viewport);
|
||||
viewportIndexes.push(viewport.index);
|
||||
|
||||
|
||||
$(viewport.element).on(StackImagePositionOffsetSynchronizer.ELEMENT_DISABLED_EVENT, this.elementDisabledHandler(this));
|
||||
});
|
||||
|
||||
@ -104,7 +104,7 @@ export class StackImagePositionOffsetSynchronizer {
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
const viewport = this.syncedViewports[i];
|
||||
|
||||
|
||||
if (viewport.element === viewportElement) {
|
||||
return viewport;
|
||||
}
|
||||
@ -155,25 +155,31 @@ export class StackImagePositionOffsetSynchronizer {
|
||||
return viewports;
|
||||
}
|
||||
|
||||
isViewportsLinkable(viewportElementA, viewportElementB) {
|
||||
const viewportAImageNormal = this.getViewportImageNormal(viewportElementA);
|
||||
const viewportBImageNormal = this.getViewportImageNormal(viewportElementB);
|
||||
|
||||
if (viewportAImageNormal && viewportBImageNormal) {
|
||||
const angleInRadians = viewportBImageNormal.angleTo(viewportAImageNormal);
|
||||
|
||||
// Pi / 12 radians = 15 degrees
|
||||
// If the angle between two vectors is Pi, it means they are just inverted
|
||||
return angleInRadians < Math.PI / 12 || angleInRadians === Math.PI;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
getLinkableViewports() {
|
||||
const activeViewportElement = this.getActiveViewportElement();
|
||||
const activeViewportImageNormal = this.getViewportImageNormal(activeViewportElement);
|
||||
const viewports = [];
|
||||
|
||||
$('.imageViewerViewport').each((index, viewportElement) => {
|
||||
const viewportImageNormal = this.getViewportImageNormal(viewportElement);
|
||||
|
||||
if (activeViewportImageNormal && viewportImageNormal) {
|
||||
const angleInRadians = viewportImageNormal.angleTo(activeViewportImageNormal);
|
||||
|
||||
// Pi / 12 radians = 15 degrees
|
||||
// If the angle between two vectors is Pi, it means they are just inverted
|
||||
if (angleInRadians < Math.PI / 12 || angleInRadians === Math.PI) {
|
||||
viewports.push({
|
||||
index: index,
|
||||
element: viewportElement
|
||||
});
|
||||
}
|
||||
if (this.isViewportsLinkable(activeViewportElement, viewportElement)) {
|
||||
viewports.push({
|
||||
index: index,
|
||||
element: viewportElement
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user