-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add simple multi-monitor support #4178
Open
wayfarer3130
wants to merge
35
commits into
master
Choose a base branch
from
feat/multi-monitor-take2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,159
−179
Open
Changes from 32 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
ed09808
feat: Multi monitor launch
wayfarer3130 efe4abd
fix: Added update to existing window
wayfarer3130 b6cf4c0
feat: Add preserved multimonitor mode
wayfarer3130 26d181d
Fix the default mode to allow multimonitor
wayfarer3130 06a4fae
Merge remote-tracking branch 'origin/master' into feat/multi-monitor-…
wayfarer3130 9abbc6c
Fix load with multimonitor not configured
wayfarer3130 bcfed7e
Exclude the app-config from terser mucking so it is readable.
wayfarer3130 ab789d7
fix tests
wayfarer3130 15d5744
Undid accidental removal of name in package.json
wayfarer3130 7052f31
Remove console logs
wayfarer3130 00419a4
Merge remote-tracking branch 'ohif/master' into feat/multi-monitor-take2
wayfarer3130 e08ea76
docs
wayfarer3130 3bc9025
Merge remote-tracking branch 'origin/master' into feat/multi-monitor-…
wayfarer3130 709c7c1
fix: Launch using new multi-monitor setup
wayfarer3130 8eb5950
Merge remote-tracking branch 'origin/master' into feat/multi-monitor-…
wayfarer3130 d18ae3a
Merge remote-tracking branch 'origin/master' into feat/multi-monitor-…
wayfarer3130 6f7e5bf
fix: Allow commandsManager commands to run on other window
wayfarer3130 652b3e6
fix: Preserve annotations by allowing commands to be run in other window
wayfarer3130 d3b0df6
Merge remote-tracking branch 'origin/master' into feat/multi-monitor-…
wayfarer3130 d7aec61
fix: Preserve multimonitor configuration
wayfarer3130 fd17be7
Fix paths when publicUrl is set
wayfarer3130 90522c1
Merge remote-tracking branch 'origin/master' into feat/multi-monitor-…
wayfarer3130 46ec727
fix: Other monitor show command
wayfarer3130 96bae40
Remove console log
wayfarer3130 ebddf4d
Merge remote-tracking branch 'origin/master' into feat/multi-monitor-…
wayfarer3130 8a680dc
fix: Multi-monitor - mostly working variant
wayfarer3130 513d8c0
fix: Add some default options
wayfarer3130 351c909
Relaunch without refresh in any windows
wayfarer3130 7d06e7b
fix: Apply full hanging protocol when changing studies
wayfarer3130 879b221
Merge remote-tracking branch 'origin/master' into feat/multi-monitor-…
wayfarer3130 ddc7787
fix: loadStudy wasn't working on same window
wayfarer3130 f5e8873
Add the simplest multi-monitor display
wayfarer3130 cfa1a6a
fix: Improve context menu behavior by checking for annotation lock st…
sedghi 9d09315
Merge branch 'master' of github.com:OHIF/Viewers into feat/multi-moni…
sedghi cf6640d
Merge remote-tracking branch 'origin/master' into feat/multi-monitor-…
wayfarer3130 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ function requestDisplaySetCreationForStudy( | |
return; | ||
} | ||
|
||
dataSource.retrieve.series.metadata({ StudyInstanceUID, madeInClient }); | ||
return dataSource.retrieve.series.metadata({ StudyInstanceUID, madeInClient }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There seems to be two files named |
||
} | ||
|
||
export default requestDisplaySetCreationForStudy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { Types } from '@ohif/core'; | ||
import { Types, DicomMetadataStore } from '@ohif/core'; | ||
|
||
import { ContextMenuController, defaultContextMenu } from './CustomizableContextMenu'; | ||
import DicomTagBrowser from './DicomTagBrowser/DicomTagBrowser'; | ||
|
@@ -16,6 +16,7 @@ import { useHangingProtocolStageIndexStore } from './stores/useHangingProtocolSt | |
import { useToggleHangingProtocolStore } from './stores/useToggleHangingProtocolStore'; | ||
import { useViewportsByPositionStore } from './stores/useViewportsByPositionStore'; | ||
import { useToggleOneUpViewportGridStore } from './stores/useToggleOneUpViewportGridStore'; | ||
import requestDisplaySetCreationForStudy from './Panels/requestDisplaySetCreationForStudy'; | ||
|
||
export type HangingProtocolParams = { | ||
protocolId?: string; | ||
|
@@ -25,6 +26,26 @@ export type HangingProtocolParams = { | |
reset?: false; | ||
}; | ||
|
||
/** | ||
* The studies from display sets gets the studies in study date | ||
* order or in study instance UID order - not very useful, but | ||
* if not specifically specified then at least making it consistent is useful. | ||
*/ | ||
const getStudiesfromDisplaySets = displaySets => { | ||
const studyMap = {}; | ||
|
||
const ret = displaySets.reduce((prev, curr) => { | ||
const { StudyInstanceUID } = curr; | ||
if (!studyMap[StudyInstanceUID]) { | ||
const study = DicomMetadataStore.getStudy(StudyInstanceUID); | ||
studyMap[StudyInstanceUID] = study; | ||
prev.push(study); | ||
} | ||
return prev; | ||
}, []); | ||
return ret; | ||
}; | ||
|
||
export type UpdateViewportDisplaySetParams = { | ||
direction: number; | ||
excludeNonImageModalities?: boolean; | ||
|
@@ -33,6 +54,7 @@ export type UpdateViewportDisplaySetParams = { | |
const commandsModule = ({ | ||
servicesManager, | ||
commandsManager, | ||
extensionManager, | ||
}: Types.Extensions.ExtensionParams): Types.Extensions.CommandsModule => { | ||
const { | ||
customizationService, | ||
|
@@ -41,12 +63,46 @@ const commandsModule = ({ | |
uiNotificationService, | ||
viewportGridService, | ||
displaySetService, | ||
multiMonitorService, | ||
} = servicesManager.services; | ||
|
||
// Define a context menu controller for use with any context menus | ||
const contextMenuController = new ContextMenuController(servicesManager, commandsManager); | ||
|
||
const actions = { | ||
/** | ||
* Runs a command in multi-monitor mode. No-op if not multi-monitor. | ||
*/ | ||
multimonitor: async options => { | ||
const { commands, screenDelta, studyInstanceUID } = options; | ||
if (multiMonitorService.numberOfScreens < 2) { | ||
return options.fallback?.(options); | ||
} | ||
|
||
await multiMonitorService.launchWindow(studyInstanceUID, screenDelta, options); | ||
if (commands) { | ||
multiMonitorService.run(screenDelta, commands, options); | ||
} | ||
}, | ||
|
||
/** | ||
* Ensures that the specified study is available for display | ||
* Then, if commands is specified, runs the given commands list/instance | ||
*/ | ||
loadStudy: async options => { | ||
const { studyInstanceUID, commands } = options; | ||
if (hangingProtocolService.hasStudyUID(studyInstanceUID)) { | ||
return commands && commandsManager.run(commands, options); | ||
} | ||
const [dataSource] = extensionManager.getActiveDataSource(); | ||
await requestDisplaySetCreationForStudy(dataSource, displaySetService, studyInstanceUID); | ||
const activeStudy = DicomMetadataStore.getStudy(studyInstanceUID); | ||
hangingProtocolService.addStudy(activeStudy); | ||
const displaySets = displaySetService.getActiveDisplaySets(); | ||
hangingProtocolService.setDisplaySets(displaySets); | ||
return commands && commandsManager.run(commands, options); | ||
}, | ||
|
||
/** | ||
* Show the context menu. | ||
* @param options.menuId defines the menu name to lookup, from customizationService | ||
|
@@ -141,6 +197,7 @@ const commandsModule = ({ | |
reset = false, | ||
}: HangingProtocolParams): boolean => { | ||
try { | ||
console.log('******** Set hanging protocol', activeStudyUID); | ||
// Stores in the state the display set selector id to displaySetUID mapping | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
// Pass in viewportId for the active viewport. This item will get set as | ||
// the activeViewportId | ||
|
@@ -169,18 +226,27 @@ const commandsModule = ({ | |
stageIndex, | ||
}); | ||
|
||
if (activeStudyUID) { | ||
hangingProtocolService.setActiveStudyUID(activeStudyUID); | ||
} | ||
const activeStudyChanged = hangingProtocolService.setActiveStudyUID(activeStudyUID); | ||
|
||
const storedHanging = `${hangingProtocolService.getState().activeStudyUID}:${protocolId}:${ | ||
const storedHanging = `${activeStudyUID || hangingProtocolService.getState().activeStudyUID}:${protocolId}:${ | ||
useStageIdx || 0 | ||
}`; | ||
|
||
const { viewportGridState } = useViewportGridStore.getState(); | ||
const restoreProtocol = !reset && viewportGridState[storedHanging]; | ||
|
||
if ( | ||
reset || | ||
(activeStudyChanged && | ||
!viewportGridState[storedHanging] && | ||
stageIndex === undefined && | ||
stageId === undefined) | ||
) { | ||
// Run the hanging protocol fresh, re-using the existing study data | ||
// This is done on reset or when the study changes and we haven't yet | ||
// applied it, and don't specify exact stage to use. | ||
hangingProtocolService.run({ activeStudyUID }, protocolId); | ||
} else if ( | ||
protocolId === hpInfo.protocolId && | ||
useStageIdx === hpInfo.stageIndex && | ||
!activeStudyUID | ||
|
@@ -562,6 +628,12 @@ const commandsModule = ({ | |
}; | ||
|
||
const definitions = { | ||
multimonitor: { | ||
commandFn: actions.multimonitor, | ||
}, | ||
loadStudy: { | ||
commandFn: actions.loadStudy, | ||
}, | ||
showContextMenu: { | ||
commandFn: actions.showContextMenu, | ||
}, | ||
|
81 changes: 81 additions & 0 deletions
81
extensions/default/src/customizations/studyBrowserContextMenu.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
export const studyBrowserContextMenu = { | ||
id: 'StudyBrowser.studyContextMenu', | ||
customizationType: 'ohif.contextMenu', | ||
menus: [ | ||
{ | ||
id: 'studyBrowserContextMenu', | ||
// selector restricts context menu to when there is nearbyToolData | ||
items: [ | ||
{ | ||
label: 'Show in Grid', | ||
commands: { | ||
commandName: 'loadStudy', | ||
commandOptions: { | ||
commands: { | ||
commandName: 'setHangingProtocol', | ||
commandOptions: { | ||
protocolId: '@ohif/mnGrid8', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
label: 'Show in other monitor', | ||
selector: ({ isMultimonitor }) => isMultimonitor, | ||
commands: { | ||
commandName: 'multimonitor', | ||
commandOptions: { | ||
commands: { | ||
commandName: 'loadStudy', | ||
commandOptions: { | ||
commands: { | ||
commandName: 'setHangingProtocol', | ||
commandOptions: { | ||
protocolId: '@ohif/mnGrid8', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
label: 'Compare All', | ||
selector: ({ isMultimonitor }) => isMultimonitor, | ||
commands: [ | ||
{ | ||
commandName: 'loadStudy', | ||
commandOptions: { | ||
commands: { | ||
commandName: 'setHangingProtocol', | ||
commandOptions: { | ||
protocolId: '@ohif/mnGrid', | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
commandName: 'multimonitor', | ||
commandOptions: { | ||
commands: { | ||
commandName: 'loadStudy', | ||
commandOptions: { | ||
commands: { | ||
commandName: 'setHangingProtocol', | ||
commandOptions: { | ||
protocolId: '@ohif/mnGridMonitor2', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
export default studyBrowserContextMenu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is only in debug mode? Sometimes the app config is huge and it is desirable to minify it