feat(toolbar): new Toolbar to enable reactive state synchronization (#3983)
This commit is contained in:
1 parent
79d5c36bda
commit
566b25a544
155 files changed
+6311
-6577
No files matched your search
@@ -2,6 +2,7 @@ import { id } from './id';
|
||||
import React, { Suspense, useMemo } from 'react';
|
||||
import getPanelModule from './getPanelModule';
|
||||
import getCommandsModule from './getCommandsModule';
|
||||
import { Types } from '@ohif/core';
|
||||
|
||||
import { useViewportGrid } from '@ohif/ui';
|
||||
import getDicomMicroscopySopClassHandler from './DicomMicroscopySopClassHandler';
|
||||
@@ -23,14 +24,14 @@ const MicroscopyViewport = props => {
|
||||
/**
|
||||
* You can remove any of the following modules if you don't need them.
|
||||
*/
|
||||
export default {
|
||||
const extension: Types.Extensions.Extension = {
|
||||
/**
|
||||
* Only required property. Should be a unique value across all extensions.
|
||||
* You ID can be anything you want, but it should be unique.
|
||||
*/
|
||||
id,
|
||||
|
||||
async preRegistration({ servicesManager, commandsManager, configuration = {}, appConfig }) {
|
||||
async preRegistration({ servicesManager }) {
|
||||
servicesManager.registerService(MicroscopyService.REGISTRATION(servicesManager));
|
||||
},
|
||||
|
||||
@@ -90,6 +91,45 @@ export default {
|
||||
];
|
||||
},
|
||||
|
||||
getToolbarModule({ servicesManager }) {
|
||||
return [
|
||||
{
|
||||
name: 'evaluate.microscopyTool',
|
||||
evaluate: ({ button }) => {
|
||||
const { microscopyService } = servicesManager.services;
|
||||
|
||||
const activeInteractions = microscopyService.getActiveInteractions();
|
||||
|
||||
const isPrimaryActive = activeInteractions.find(interactions => {
|
||||
const sameMouseButton = interactions[1].bindings.mouseButtons.includes('left');
|
||||
|
||||
if (!sameMouseButton) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const notDraw = interactions[0] !== 'draw';
|
||||
|
||||
// there seems to be a custom logic for draw tool for some reason
|
||||
return notDraw
|
||||
? interactions[0] === button.id
|
||||
: interactions[1].geometryType === button.id;
|
||||
});
|
||||
|
||||
return {
|
||||
disabled: false,
|
||||
className: isPrimaryActive
|
||||
? '!text-black bg-primary-light'
|
||||
: '!text-common-bright hover:!bg-primary-dark hover:!text-primary-light',
|
||||
// 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,
|
||||
};
|
||||
},
|
||||
},
|
||||
];
|
||||
},
|
||||
|
||||
/**
|
||||
* SopClassHandlerModule should provide a list of sop class handlers that will be
|
||||
* available in OHIF for Modes to consume and use to create displaySets from Series.
|
||||
@@ -113,3 +153,5 @@ export default {
|
||||
|
||||
getCommandsModule,
|
||||
};
|
||||
|
||||
export default extension;
|
||||
Reference in new issue
Block a user