-
-
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(toolbar): new Toolbar to enable reactive state synchronization #3983
Conversation
***Add button condition for toolGroup.id !== 'mpr'*** ***Update ListMenu component to handle disabled items*** ***Add evaluateToolbarButtonState module
…rButton components
***Description:*** This commit updates the SyncGroupService, segmentationButtons, and MeasurementService files. In SyncGroupService, the code has been modified to handle cases where the renderingEngine is not found for a given viewportId. It now falls back to the first renderingEngine in the list. In segmentationButtons, the default values for the brush size, eraser size, and threshold size have been changed from 15 to 25. In MeasurementService, the unmappedMeasurements variable has been changed from a Set to a Map. Additionally, a new error handling logic has been added to handle cases where mapping fails. In toolbar.md, a new section has been added to explain how to change the toolbar based on the hanging protocol. ***Note:
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3983 +/- ##
==========================================
- Coverage 46.23% 44.41% -1.83%
==========================================
Files 78 80 +2
Lines 1276 1333 +57
Branches 312 327 +15
==========================================
+ Hits 590 592 +2
- Misses 548 588 +40
- Partials 138 153 +15
... and 8 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
platform/ui/src/components/SplitButtonToolbar/SplitButtonToolbar.tsx
Outdated
Show resolved
Hide resolved
platform/ui/src/components/SplitButtonToolbar/__stories__/splitButtonToolbar.stories.mdx
Outdated
Show resolved
Hide resolved
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.
Looks wonderful - very much looking forward to having this in.
This PR will address some fundamental issues with the current implementation of the toolbar and toolbar service.
Fixing these
There were so many things wrong with our toolbar, where to synchronize the button states
with the tool state you should have activated the tool via
toolbarService.recordInteraction
whichwas horrible.
This PR will add a new concept of
evaluators
for each button, which will be used to determine thestate of the button based on the app context.
There are some breaking changes in this PR, but I think they are necessary to make the toolbar more
flexible and easier to use. We will talk about the breaking changes later down
Reactive Toolbar
Addressing
By the introduction of the evaluators, the toolbar will be reactive to the viewports and tooLGroups see below movie
Area.mp4
Flexible Button Sections
You can assign any button to any section you want, in your extensions you can provide a
template that accepts button section and in your modes you should be able to assign buttons
to it.
We have created a new general
ToolBox
component that you can use as many time as you wantwith different section names. We are shipping it for the segmentation mode for now.
You should be able to do the following for instance
by saying
and you should be able to modify the segmentation toolbox initial setup too via your modes by assigning buttons.
above as you see we use
commands
to set the most updated option value via a command, also you could have more sophisticated option change handling such asYou can now have toolbox (in a modal) with tools and advanced options inside and everything will be synced in terms of state
Read more in Toolbar.md
initial states for toggles
Addressing
Now you can set the toggles initially and start the viewer with them, e.g., start viewer by reference lines on
You only need to active/enable them in the
initToolGroups
and everything will workHotkeys synchronization with toolbar (in progress)
Will address this
Breaking Changes
activeTool
and their getter and setter is removed. The active toolshould be derived by the toolGroup and the viewport and by manually settings it.
action need to be taken
Since tools are setup to be (active, passive, disabled and enabled) by the toolGroup
in
initToolGroups
you shouldn't worry about this, and after this PR we willautomatically set the active tool based on the toolGroup and the viewport.
The only thing as a
Mode
writer you should do is to write what buttons you have andwhere you want to put them, as simple as
toggle
,action
ortool
.Buttons now are just buttons, which are some properties (icon, label, etc.) with
commands
that willrun (by toolbarService) after interaction. Evaluators will be used to determine the state of the button
(color, disabled etc.)
remove the
type
property from the buttons, and instead use the uiType for the top level ui type def.old implementation
New implementation
(Notice the uiType)
(we will talk about the
evaluate
property later down)In addition, the previous signature of button definition (
ToolbarService.createButton
), which relied on positional arguments, is removed and replaced by a more flexible object-based definition.**old implementation **
New implementation
(notice the object based definition in the new implementation)
(we will talk about the
evaluate
property next)Add the proper
evaluate
property to the button definition, which will be used to determine the state of the buttonbased on the app context.
You can check out the
modes/longitudinal/src/toolbarButtons.ts
for the usage of theevaluate
property.But in general
evaluate.cornerstoneTool
if you want the button to be highlighted if it is only on active primary (left mouse)evaluate.cornerstoneTool.toggle
if the tool is a toggle tool (like reference lines or image overlay)Changes & Results
Testing
Checklist
PR
semantic-release format and guidelines.
Code
etc.)
Public Documentation Updates
additions or removals.
Tested Environment