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';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
|
||||||
Meteor.startup(() => {
|
Meteor.startup(() => {
|
||||||
|
const { toolManager } = OHIF.viewerbase;
|
||||||
|
const contextName = 'viewer';
|
||||||
|
|
||||||
// Enable the custom tools
|
// Enable the custom tools
|
||||||
const customTools = [{
|
const customTools = [{
|
||||||
|
id: 'bidirectional',
|
||||||
|
name: 'Target'
|
||||||
|
}, {
|
||||||
id: 'nonTarget',
|
id: 'nonTarget',
|
||||||
name: 'Non-Target'
|
name: 'Non-Target'
|
||||||
}, {
|
}, {
|
||||||
@ -14,12 +20,25 @@ Meteor.startup(() => {
|
|||||||
id: 'targetUN',
|
id: 'targetUN',
|
||||||
name: 'UN Target'
|
name: 'UN Target'
|
||||||
}];
|
}];
|
||||||
|
|
||||||
customTools.forEach(tool => {
|
customTools.forEach(tool => {
|
||||||
_.defaults(OHIF.hotkeys.defaults.viewer, { [tool.id]: '' });
|
_.defaults(OHIF.hotkeys.defaults.viewer, { [tool.id]: '' });
|
||||||
OHIF.commands.register('viewer', tool.id, {
|
OHIF.commands.register(contextName, tool.id, {
|
||||||
name: tool.name,
|
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,
|
studyInstanceUids: studyInstanceUids,
|
||||||
patientId: relatedStudies[0].patientId,
|
patientId: relatedStudies[0].patientId,
|
||||||
earliestDate: studyDates[0],
|
earliestDate: studyDates[0],
|
||||||
latestDate: studyDates[studyDates.length - 1]
|
latestDate: studyDates[studyDates.length - 1],
|
||||||
|
isLocked: false
|
||||||
};
|
};
|
||||||
|
|
||||||
// Insert this timepoint into the Timepoints Collection
|
// Insert this timepoint into the Timepoints Collection
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { $ } from 'meteor/jquery';
|
import { $ } from 'meteor/jquery';
|
||||||
|
import { _ } from 'meteor/underscore';
|
||||||
import { OHIF } from 'meteor/ohif:core';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
import 'meteor/ohif:viewerbase';
|
import 'meteor/ohif:viewerbase';
|
||||||
|
|
||||||
@ -63,7 +64,15 @@ function renderIntoViewport(viewportIndex, studyInstanceUid, seriesInstanceUid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
function syncViewports(viewportsIndexes) {
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -155,26 +155,32 @@ export class StackImagePositionOffsetSynchronizer {
|
|||||||
return viewports;
|
return viewports;
|
||||||
}
|
}
|
||||||
|
|
||||||
getLinkableViewports() {
|
isViewportsLinkable(viewportElementA, viewportElementB) {
|
||||||
const activeViewportElement = this.getActiveViewportElement();
|
const viewportAImageNormal = this.getViewportImageNormal(viewportElementA);
|
||||||
const activeViewportImageNormal = this.getViewportImageNormal(activeViewportElement);
|
const viewportBImageNormal = this.getViewportImageNormal(viewportElementB);
|
||||||
const viewports = [];
|
|
||||||
|
|
||||||
$('.imageViewerViewport').each((index, viewportElement) => {
|
if (viewportAImageNormal && viewportBImageNormal) {
|
||||||
const viewportImageNormal = this.getViewportImageNormal(viewportElement);
|
const angleInRadians = viewportBImageNormal.angleTo(viewportAImageNormal);
|
||||||
|
|
||||||
if (activeViewportImageNormal && viewportImageNormal) {
|
|
||||||
const angleInRadians = viewportImageNormal.angleTo(activeViewportImageNormal);
|
|
||||||
|
|
||||||
// Pi / 12 radians = 15 degrees
|
// Pi / 12 radians = 15 degrees
|
||||||
// If the angle between two vectors is Pi, it means they are just inverted
|
// If the angle between two vectors is Pi, it means they are just inverted
|
||||||
if (angleInRadians < Math.PI / 12 || angleInRadians === Math.PI) {
|
return angleInRadians < Math.PI / 12 || angleInRadians === Math.PI;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
getLinkableViewports() {
|
||||||
|
const activeViewportElement = this.getActiveViewportElement();
|
||||||
|
const viewports = [];
|
||||||
|
|
||||||
|
$('.imageViewerViewport').each((index, viewportElement) => {
|
||||||
|
if (this.isViewportsLinkable(activeViewportElement, viewportElement)) {
|
||||||
viewports.push({
|
viewports.push({
|
||||||
index: index,
|
index: index,
|
||||||
element: viewportElement
|
element: viewportElement
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return viewports;
|
return viewports;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user