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(toolbar): new Toolbar to enable reactive state synchronization #3983

Merged
merged 88 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
689d2c7
Remove unused storeContexts from commandsModule
sedghi Feb 21, 2024
98844c4
Refactor code and fix linting issues
sedghi Feb 21, 2024
d15c4ea
clean up mode tsx
sedghi Feb 21, 2024
d554aa9
Add AppContextService and update contextProviders
sedghi Feb 22, 2024
b9e6dd0
Refactor toolbar and remove unused code
sedghi Feb 22, 2024
066e2dc
Refactor toolbar buttons and add tooltips
sedghi Feb 22, 2024
f91eb94
Update Toolbar and ViewportGrid components
sedghi Feb 22, 2024
8fc36e5
Refactor UI and contextProviders modules
sedghi Feb 22, 2024
1b098cc
Add disabled state to toolbar buttons and side panel tabs
sedghi Feb 22, 2024
dbe5214
Refactor ViewerLayout and App components
sedghi Feb 22, 2024
03187bd
Refactor toolbar button handling and add display set condition
sedghi Feb 23, 2024
c4455cf
Refactor toolbar button handling logic
sedghi Feb 23, 2024
8892b16
Add button condition for displaySets.isReconstructable***
sedghi Feb 23, 2024
7a9735c
Refactor toolbar button evaluation and update list menu theme
sedghi Feb 23, 2024
e9554e1
Remove isActive property from moreTools and toolbarButtons
sedghi Feb 23, 2024
8035802
Refactor toolbar button state handling
sedghi Feb 23, 2024
fb39375
Refactor toolbar button toggling logic
sedghi Feb 23, 2024
1666c73
Refactor Toolbar component and ToolbarService
sedghi Feb 23, 2024
e2b6f19
Add SplitButtonToolbar component
sedghi Feb 26, 2024
869c80f
clean up
sedghi Feb 26, 2024
8b307a0
Update dependencies in package.json
sedghi Feb 26, 2024
0be2f51
remove toolbarservice init
sedghi Feb 26, 2024
b34cf95
Refactor toolbarButtons.js and commandsModule.ts
sedghi Feb 26, 2024
8154820
Fix toolbar button and interaction issues
sedghi Feb 26, 2024
e8c350b
Fix toolGroup method calls in commandsModule and init.tsx
sedghi Feb 27, 2024
d5d8024
Update Cornerstone extension: remove unused code and add toolbar module
sedghi Feb 28, 2024
bd55f08
Refactor button background classes and remove unused props
sedghi Feb 28, 2024
7520f77
Refactor toolbar buttons and evaluate functions
sedghi Feb 28, 2024
d88f95e
add nested button support for new architecture
sedghi Feb 28, 2024
fad70dc
Fix UI styling issues in IconButton, Toolbar, SplitButton, and Toolba…
sedghi Feb 28, 2024
1f6283a
Update toolbar module styling
sedghi Feb 28, 2024
9f21e1e
Remove commented out code in ToolbarService.ts
sedghi Feb 28, 2024
1992370
Remove moreToolsMpr import and related code
sedghi Feb 28, 2024
516344d
new api for toolbar buttons for all modes
sedghi Feb 28, 2024
846584f
Refactor UI styling and remove unnecessary code
sedghi Feb 29, 2024
71de18c
Refactor toolbar evaluation and button props
sedghi Feb 29, 2024
ae3ac01
Remove cleanUpCrosshairs command and update getToolbarModule
sedghi Feb 29, 2024
2fcf360
Refactor image slice synchronization
sedghi Feb 29, 2024
f5fa155
Update dependencies and fix toolbar button styling
sedghi Feb 29, 2024
1ea33b3
Fix code formatting and update type annotations
sedghi Mar 5, 2024
07f64b3
Remove unused code and functions
sedghi Mar 5, 2024
1126466
Fix evaluate.group.promoteToPrimaryIfCornerstoneToolNotActiveInTheList
sedghi Mar 5, 2024
e018490
Merge branch 'master' of github.com:OHIF/Viewers into feat/app-context
sedghi Mar 7, 2024
cace7ee
general toolbox component
sedghi Mar 7, 2024
ce58dd8
Add ToolWithStackedOptions component and segmentation buttons to toolbar
sedghi Mar 7, 2024
5e44242
Add Toolbox component and ToolboxContainer to default extension
sedghi Mar 7, 2024
312aa8c
Remove Toolbox component and update button section in Segmentation mode
sedghi Mar 8, 2024
5a1b52a
cine service
sedghi Mar 8, 2024
7c162ed
Remove AppContextService and AppContextProvider
sedghi Mar 8, 2024
b8780df
Update IconButton variant classes
sedghi Mar 8, 2024
68c4f2d
Refactor toolbarButtons.js and init.js
sedghi Mar 8, 2024
91f760b
isReady
sedghi Mar 8, 2024
ac96a14
Update positions of categories in JSON files and remove unused code
sedghi Mar 8, 2024
cd6934f
Refactor tooltips to display secondary content
sedghi Mar 8, 2024
10cacf0
Update dependencies and remove unused code
sedghi Mar 8, 2024
a3f9f7e
Add toolbar event registration for cornerstone tools
sedghi Mar 11, 2024
e44ffbf
Update Command and Toolbar Modules
sedghi Mar 12, 2024
1757d9f
Remove unused options from commandsModule
sedghi Mar 12, 2024
51b0c87
apply review comments
sedghi Mar 12, 2024
b8bbd55
Update canvas width and height for maintaining aspect ratio in thumbn…
sedghi Mar 14, 2024
0d67e22
toggle sync with sync id
sedghi Mar 14, 2024
ac22228
Update getViewportModule to include commandsManager parameter
sedghi Mar 14, 2024
c3040f8
Add file loader for wasm file and import ToolbarButton in SplitButton…
sedghi Mar 21, 2024
ce0cd92
fix button group stuff
sedghi Mar 21, 2024
2155d86
Update canvas width and height for thumbnail images
sedghi Mar 21, 2024
773c3cc
Update segmentation toolbox buttons
sedghi Mar 22, 2024
808fc5d
Refactor toolbar buttons and button groups
sedghi Mar 22, 2024
acc7aae
Update button sizes and icons
sedghi Mar 22, 2024
f1396cd
Add ToolboxUI component and update imports
sedghi Mar 25, 2024
3754871
Update imports and components in codebase
sedghi Mar 25, 2024
0e491d6
Add ToolboxProvider to App component and pass props to Toolbox component
sedghi Mar 25, 2024
6f3753b
Refactor evaluate function in getToolbarModule and segmentationButtons
sedghi Mar 25, 2024
df68d29
Merge branch 'master' of github.com:OHIF/Viewers into feat/app-context
sedghi Mar 25, 2024
47cde98
Fix issue with URL object creation in updateAuthServiceAndCleanUrl fu…
sedghi Mar 25, 2024
7aa8ed6
Add toolbarButtons import and update documentation
sedghi Mar 25, 2024
870ad9e
Refactor toolbarButtons.js
sedghi Mar 25, 2024
f616dd8
Refactor UI components and fix styling issues
sedghi Mar 25, 2024
49b076d
Add new toolbar buttons and update button styles
sedghi Mar 25, 2024
536285c
Remove unnecessary code in MPR.spec.js
sedghi Mar 25, 2024
d217cda
Toggle ReferenceLines and ImageOverlayViewer tools
sedghi Mar 25, 2024
030280e
Update SyncGroupService, segmentationButtons, and MeasurementService***
sedghi Mar 25, 2024
ad06de6
unit tests
sedghi Mar 25, 2024
6964eef
fix e2e tests
sedghi Mar 25, 2024
03129c4
Refactor UI components and update imports
sedghi Mar 27, 2024
1a3ee1f
remove spellcheck for no
sedghi Mar 27, 2024
2a8c7bf
Add toggleThresholdRangeAndDynamic command and dynamicRadius configur…
sedghi Mar 27, 2024
30a167e
Update ToolbarButton and commandsModule components
sedghi Mar 27, 2024
2141064
review comment
sedghi Mar 27, 2024
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 .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ version: 2.1
##
orbs:
codecov: codecov/[email protected]
cypress: cypress-io/cypress@3.2.1
cypress: cypress-io/cypress@3.3.1

executors:
cypress-custom:
Expand Down
40 changes: 40 additions & 0 deletions extensions/cornerstone-dicom-seg/src/commandsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from '@cornerstonejs/tools';
import { adaptersRT, helpers, adaptersSEG } from '@cornerstonejs/adapters';
import { classes, DicomMetadataStore } from '@ohif/core';
import { utilities } from '@cornerstonejs/tools';

import vtkImageMarchingSquares from '@kitware/vtk.js/Filters/General/ImageMarchingSquares';
import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
Expand All @@ -18,6 +19,7 @@ import {
getUpdatedViewportsForSegmentation,
getTargetViewport,
} from './utils/hydrationUtils';
const { segmentation: segmentationUtils } = utilities;

const { datasetToBlob } = dcmjs.data;

Expand Down Expand Up @@ -45,6 +47,7 @@ const commandsModule = ({
uiDialogService,
displaySetService,
viewportGridService,
toolGroupService,
} = (servicesManager as ServicesManager).services;

const actions = {
Expand Down Expand Up @@ -397,6 +400,36 @@ const commandsModule = ({
console.warn(e);
}
},
setBrushSize: ({ value, toolNames }) => {
const brushSize = Number(value);

toolGroupService.getToolGroupIds()?.forEach(toolGroupId => {
if (toolNames?.length === 0) {
segmentationUtils.setBrushSizeForToolGroup(toolGroupId, brushSize);
} else {
toolNames?.forEach(toolName => {
segmentationUtils.setBrushSizeForToolGroup(toolGroupId, brushSize, toolName);
});
}
});
},
setThresholdRange: ({
values,
toolNames = ['ThresholdCircularBrush', 'ThresholdSphereBrush'],
}) => {
toolGroupService.getToolGroupIds()?.forEach(toolGroupId => {
const toolGroup = toolGroupService.getToolGroup(toolGroupId);
toolNames?.forEach(toolName => {
toolGroup.setToolConfiguration(toolName, {
strategySpecificConfiguration: {
THRESHOLD: {
threshold: values,
},
},
});
});
});
},
};

const definitions = {
Expand Down Expand Up @@ -424,11 +457,18 @@ const commandsModule = ({
downloadRTSS: {
commandFn: actions.downloadRTSS,
},
setBrushSize: {
commandFn: actions.setBrushSize,
},
setThresholdRange: {
commandFn: actions.setThresholdRange,
},
};

return {
actions,
definitions,
defaultContext: 'SEGMENTATION',
};
};

Expand Down
15 changes: 11 additions & 4 deletions extensions/cornerstone-dicom-seg/src/getPanelModule.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import React from 'react';

import { useAppConfig } from '@state';
import { Toolbox } from '@ohif/ui';
import PanelSegmentation from './panels/PanelSegmentation';
import SegmentationToolbox from './panels/SegmentationToolbox';

const getPanelModule = ({ commandsManager, servicesManager, extensionManager, configuration }) => {
const getPanelModule = ({
commandsManager,
servicesManager,
extensionManager,
configuration,
title,
}) => {
const { customizationService } = servicesManager.services;

const wrappedPanelSegmentation = configuration => {
Expand All @@ -26,13 +32,14 @@ const getPanelModule = ({ commandsManager, servicesManager, extensionManager, co
};

const wrappedPanelSegmentationWithTools = configuration => {
const [appConfig] = useAppConfig();
return (
<>
<SegmentationToolbox
<Toolbox
commandsManager={commandsManager}
servicesManager={servicesManager}
extensionManager={extensionManager}
buttonSectionId="segmentationToolbox"
title="Segmentation Tools"
configuration={{
...configuration,
}}
Expand Down
65 changes: 65 additions & 0 deletions extensions/cornerstone-dicom-seg/src/getToolbarModule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
export function getToolbarModule({ commandsManager, servicesManager }) {
const { segmentationService, toolGroupService } = servicesManager.services;
return [
{
name: 'evaluate.cornerstone.segmentation',
evaluate: ({ viewportId, button, toolNames }) => {
// Todo: we need to pass in the button section Id since we are kind of
// forcing the button to have black background since initially
// it is designed for the toolbox not the toolbar on top
// we should then branch the buttonSectionId to have different styles
const segmentations = segmentationService.getSegmentations();
if (!segmentations?.length) {
return {
disabled: true,
className: '!text-common-bright !bg-black opacity-50',
};
}

const toolGroup = toolGroupService.getToolGroupForViewport(viewportId);

if (!toolGroup) {
return;
}

const toolName = getToolNameForButton(button);

if (!toolGroup || !toolGroup.hasTool(toolName)) {
return {
disabled: true,
className: '!text-common-bright ohif-disabled',
};
}

const isPrimaryActive = toolNames
? toolNames.includes(toolGroup.getActivePrimaryMouseButtonTool())
: toolGroup.getActivePrimaryMouseButtonTool() === toolName;

return {
disabled: false,
className: isPrimaryActive
? '!text-black !bg-primary-light hover:bg-primary-light hover-text-black hover:cursor-pointer'
: '!text-common-bright !bg-black hover:bg-primary-light hover:cursor-pointer hover:text-black',
// Todo: isActive right now is used for nested buttons where the primary
// button needs to be fully rounded (vs partial rounded) when active
// otherwise it does not have any other use
isActive: isPrimaryActive,
};
},
},
];
}

function getToolNameForButton(button) {
const { props } = button;

const commands = props?.commands || button.commands;

if (commands && commands.length) {
const command = commands[0];
const { commandOptions } = command;
const { toolName } = commandOptions || { toolName: props?.id ?? button.id };
return toolName;
}
return null;
}
6 changes: 3 additions & 3 deletions extensions/cornerstone-dicom-seg/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import getSopClassHandlerModule from './getSopClassHandlerModule';
import getHangingProtocolModule from './getHangingProtocolModule';
import getPanelModule from './getPanelModule';
import getCommandsModule from './commandsModule';
import { getToolbarModule } from './getToolbarModule';
import preRegistration from './init';

const Component = React.lazy(() => {
Expand All @@ -29,7 +30,6 @@ const extension = {
*/
id,
preRegistration,

/**
* PanelModule should provide a list of panels that will be available in OHIF
* for Modes to consume and render. Each panel is defined by a {name,
Expand All @@ -38,8 +38,8 @@ const extension = {
*/
getPanelModule,
getCommandsModule,

getViewportModule({ servicesManager, extensionManager }) {
getToolbarModule,
getViewportModule({ servicesManager, extensionManager, commandsManager }) {
const ExtendedOHIFCornerstoneSEGViewport = props => {
return (
<OHIFCornerstoneSEGViewport
Expand Down
2 changes: 1 addition & 1 deletion extensions/cornerstone-dicom-seg/src/init.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { addTool, BrushTool } from '@cornerstonejs/tools';

export default function init({ configuration = {} }): void {
export default function init({ servicesManager }): void {
addTool(BrushTool);
}
Loading
Loading