-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(toolbar): new Toolbar to enable reactive state synchronization (#…
- Loading branch information
Showing
155 changed files
with
6,237 additions
and
6,503 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
|
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -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; | ||
} |
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,5 +1,5 @@ | ||
import { addTool, BrushTool } from '@cornerstonejs/tools'; | ||
|
||
export default function init({ configuration = {} }): void { | ||
export default function init({ servicesManager }): void { | ||
addTool(BrushTool); | ||
} |
Oops, something went wrong.