Skip to content
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: Compatibility with new hp/toolbar buttons only #33

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modes/veterinary-mode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"peerDependencies": {
"@ohif/core": "^3.0.0",
"@radicalimaging/config-mode": "^3.4.2",
"@radicalimaging/findings-mode": "^3.4.2"
"@radicalimaging/findings-mode": "^3.13.4"
},
"dependencies": {
"@babel/runtime": "7.17.9"
Expand Down
4 changes: 2 additions & 2 deletions ohif-configurable/config-mode/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@radicalimaging/config-mode",
"version": "3.13.2",
"version": "3.13.5",
"description": "A configurable/themeable mode that allows runtime extensions to the mode.",
"author": "Radical Imaging",
"license": "MIT",
Expand Down Expand Up @@ -33,7 +33,7 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@cornerstonejs/tools": "^0.63.3",
"@cornerstonejs/tools": "^1.11.2",
"@ohif/core": "^3.0.0",
"@ohif/ui": "^1.10.10",
"gl-matrix": "^3.4.3",
Expand Down
20 changes: 11 additions & 9 deletions ohif-configurable/config-mode/src/onModeEnter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export default function onModeEnter({ servicesManager, extensionManager, commandsManager }) {
export default function onModeEnter(props) {
const { servicesManager, extensionManager, commandsManager } = props;
const {
measurementService,
ToolBarService,
ToolGroupService,
toolbarService,
toolGroupService,
customizationService,
} = servicesManager.services;

Expand All @@ -15,7 +16,8 @@ export default function onModeEnter({ servicesManager, extensionManager, command
let unsubscribe;

const activateTool = () => {
ToolBarService.recordInteraction(this.defaultTool);
toolbarService.recordInteraction(this.defaultTool);
this.activateOtherTools?.(props);

// We don't need to reset the active tool whenever a viewport is getting
// added to the toolGroup.
Expand All @@ -24,15 +26,15 @@ export default function onModeEnter({ servicesManager, extensionManager, command

// Since we only have one viewport for the basic cs3d mode and it has
// only one hanging protocol, we can just use the first viewport
({ unsubscribe } = ToolGroupService.subscribe(
ToolGroupService.EVENTS.VIEWPORT_ADDED,
({ unsubscribe } = toolGroupService.subscribe(
toolGroupService.EVENTS.VIEWPORT_ADDED,
activateTool
));

ToolBarService.init(extensionManager);
ToolBarService.addButtons(this.toolbarButtons);
toolbarService.init(extensionManager);
toolbarService.addButtons(this.toolbarButtons);
Object.keys(this.toolBarSections).forEach(section => {
ToolBarService.createButtonSection(section, this.toolBarSections[section]);
toolbarService.createButtonSection(section, this.toolBarSections[section]);
});

customizationService?.addModeCustomizations?.(this.modeCustomizations);
Expand Down
55 changes: 33 additions & 22 deletions ohif-configurable/config-mode/src/toolbarButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import {
WindowLevelMenuItem,
} from '@ohif/ui';
import { defaults } from '@ohif/core';
import { EVENTS } from '@cornerstonejs/core';

const isNewHP = window.config.isNewHP;
console.log("EVENTS=", EVENTS);

const { windowLevelPresets } = defaults;
/**
Expand All @@ -17,32 +18,49 @@ const { windowLevelPresets } = defaults;
* @param {*} icon
* @param {*} label
*/
function _createButton(type, id, icon, label, commands, tooltip) {
function _createButton(type, id, icon, label, commands, tooltip, extraOptions) {
return {
id,
icon,
label,
type,
commands,
tooltip,
...extraOptions,
};
}

function _createCommands(commandName, toolName, toolGroupIds) {
return toolGroupIds.map(toolGroupId => ({
/* It's a command that is being run when the button is clicked. */
commandName,
const _createActionButton = _createButton.bind(null, 'action');
const _createToggleButton = _createButton.bind(null, 'toggle');
const _createToolButton = _createButton.bind(null, 'tool');

const ReferenceLinesCommands = [
{
commandName: 'setSourceViewportForReferenceLinesTool',
context: 'CORNERSTONE',
},
{
commandName: 'setToolActive',
commandOptions: {
toolName,
toolGroupId,
toolName: 'ReferenceLines',
},
context: 'CORNERSTONE',
}));
}
},
];

const _createActionButton = _createButton.bind(null, 'action');
const _createToggleButton = _createButton.bind(null, 'toggle');
const _createToolButton = _createButton.bind(null, 'tool');
const ReferenceLines = _createToggleButton(
'ReferenceLines',
'tool-referenceLines', // change this with the new icon
'Reference Lines',
ReferenceLinesCommands,
'Show reference lines',
{
listeners: {
activeViewportIdChanged: ReferenceLinesCommands,
[EVENTS.STACK_VIEWPORT_NEW_STACK]: ReferenceLinesCommands,
},
}
);

/**
*
Expand Down Expand Up @@ -384,7 +402,6 @@ const toolbarButtons = [
// ************ New Layout Section

// Measurement
isNewHP ?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just get rid of the old menu as the new one has been around for a while - uses the new hanging protocol service.

{
id: 'Layout',
type: 'ohif.splitButton',
Expand Down Expand Up @@ -478,15 +495,7 @@ const toolbarButtons = [
},
],
},
} :
{
id: 'Layout',
type: 'ohif.layoutSelector',
props: {
rows: 3,
columns: 3,
},
},

{
id: 'MPR',
Expand Down Expand Up @@ -596,6 +605,7 @@ const toolbarButtons = [
context: 'CORNERSTONE',
},
]),
ReferenceLines,
_createToggleButton(
'ReferenceLines',
'tool-referenceLines', // change this with the new icon
Expand Down Expand Up @@ -698,4 +708,5 @@ const toolbarButtons = [
},
];

console.log("* config-mode toolbarButtons", toolbarButtons);
export default toolbarButtons;
2 changes: 1 addition & 1 deletion ohif-configurable/findings-mode/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@radicalimaging/findings-mode",
"version": "3.13.3",
"version": "3.13.4",
"description": "Support context menu/command key findings",
"author": "Bill Wallace, Radical Imaging",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion ohif-configurable/hp-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"start": "yarn run dev"
},
"peerDependencies": {
"@cornerstonejs/tools": "^0.63.3",
"@cornerstonejs/tools": "^1.11.2",
"@ohif/core": "^3.0.0",
"@ohif/extension-cornerstone": "^3.0.0",
"@ohif/extension-default": "^3.0.0",
Expand Down