diff --git a/extensions/cornerstone/src/toolbarModule.js b/extensions/cornerstone/src/toolbarModule.js index 801466f9b..a06893ad5 100644 --- a/extensions/cornerstone/src/toolbarModule.js +++ b/extensions/cornerstone/src/toolbarModule.js @@ -47,7 +47,7 @@ const definitions = [ { id: 'Zoom', label: 'Zoom', - icon: 'search-plus', + icon: 'tool-zoom', // type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE, commandName: 'setToolActive', diff --git a/extensions/default/src/getLayoutTemplateModule.js b/extensions/default/src/getLayoutTemplateModule.js index 550803789..a2c0d1d61 100644 --- a/extensions/default/src/getLayoutTemplateModule.js +++ b/extensions/default/src/getLayoutTemplateModule.js @@ -18,7 +18,7 @@ export default function() { ]; } -const Header = () => { +const Header = ({ tools, moreTools }) => { const [activeTool, setActiveTool] = useState('Zoom'); const dropdownContent = [ { @@ -30,6 +30,7 @@ const Header = () => { { name: 'Bone', value: '2500 / 480' }, { name: 'Brain', value: '80 / 40' }, ]; + /* const tools = [ { id: 'Zoom', @@ -90,6 +91,7 @@ const Header = () => { onClick: () => setActiveTool('Layout'), }, ]; + */ return (
@@ -106,7 +108,11 @@ const Header = () => {
- +
@@ -128,45 +134,45 @@ const Header = () => { ); }; -const ViewportToolbar = () => { - const tools = [ - { - id: 'Annotate', - label: 'Annotate', - icon: 'tool-annotate', - type: null, - commandName: 'setToolActive', - commandOptions: { toolName: 'Annotate' }, - onClick: () => console.log('Activate Annotate'), - }, - { - id: 'Bidirectional', - label: 'Bidirectional', - icon: 'tool-bidirectional', - type: null, - commandName: 'setToolActive', - commandOptions: { toolName: 'Bidirectional' }, - onClick: () => console.log('Activate Bidirectional'), - }, - { - id: 'Elipse', - label: 'Elipse', - icon: 'tool-elipse', - type: null, - commandName: 'setToolActive', - commandOptions: { toolName: 'Elipse' }, - onClick: () => console.log('Activate Elipse'), - }, - { - id: 'Length', - label: 'Length', - icon: 'tool-length', - type: null, - commandName: 'setToolActive', - commandOptions: { toolName: 'Length' }, - onClick: () => console.log('Activate Length'), - }, - ]; +const ViewportToolbar = ({ tools }) => { + // const tools = [ + // { + // id: 'Annotate', + // label: 'Annotate', + // icon: 'tool-annotate', + // type: null, + // commandName: 'setToolActive', + // commandOptions: { toolName: 'Annotate' }, + // onClick: () => console.log('Activate Annotate'), + // }, + // { + // id: 'Bidirectional', + // label: 'Bidirectional', + // icon: 'tool-bidirectional', + // type: null, + // commandName: 'setToolActive', + // commandOptions: { toolName: 'Bidirectional' }, + // onClick: () => console.log('Activate Bidirectional'), + // }, + // { + // id: 'Elipse', + // label: 'Elipse', + // icon: 'tool-elipse', + // type: null, + // commandName: 'setToolActive', + // commandOptions: { toolName: 'Elipse' }, + // onClick: () => console.log('Activate Elipse'), + // }, + // { + // id: 'Length', + // label: 'Length', + // icon: 'tool-length', + // type: null, + // commandName: 'setToolActive', + // commandOptions: { toolName: 'Length' }, + // onClick: () => console.log('Activate Length'), + // }, + // ]; return ; }; @@ -197,9 +203,14 @@ function viewerLayout({ console.warn(displaySetInstanceUids); console.warn(toolBarLayout); + const [primaryToolBarLayout, secondaryToolBarLayout] = toolBarLayout; + return (
-
+
- +
{/* ); } + +viewerLayout.defaultProps = { + toolBarLayout: [ + { tools: [], moreTools: [] }, + { tools: [], moreTools: [] }, + ], +}; diff --git a/modes/example/src/index.js b/modes/example/src/index.js index a503be405..b6e91f746 100644 --- a/modes/example/src/index.js +++ b/modes/example/src/index.js @@ -24,12 +24,19 @@ export default function mode({ modeConfiguration }) { }, ]); + debugger; + // Could import layout selector here from org.ohif.default (when it exists!) toolBarManager.setToolBarLayout([ // Primary - ['StackScroll', { label: 'More', subMenu: ['Zoom'] }], + { + tools: ['Zoom'], + moreTools: ['Zoom'], + }, // Secondary - ['StackScroll'], + { + tools: ['Zoom'], + }, ]); }, layoutTemplate: ({ routeProps }) => { diff --git a/platform/core/src/ToolBarManager.js b/platform/core/src/ToolBarManager.js index 15eb84169..4f06788c5 100644 --- a/platform/core/src/ToolBarManager.js +++ b/platform/core/src/ToolBarManager.js @@ -2,7 +2,7 @@ export default class toolBarManager { constructor(extensionManager, setToolBarLayout) { this.buttons = {}; this.extensionManager = extensionManager; - this.setToolBarLayout = setToolBarLayout; + this.viewModelContextSetToolBarLayout = setToolBarLayout; } addButtons(buttons) { @@ -22,34 +22,34 @@ export default class toolBarManager { setToolBarLayout(layouts) { const toolBarLayout = []; + debugger; + console.log('setToolBarLayout'); + layouts.forEach(layout => { - const toolBarDefinitions = []; + const toolBarDefinitions = { tools: [], moreTools: [] }; - layout.forEach(element => { - if (typeof element === 'object') { - // process submenu. + const { tools, moreTools } = layout; - const subMenuDefinition = { label: element.label, subMenu: [] }; - - element.subMenu.forEach(subMenuElement => { - const button = this.buttons[subMenuElement]; - - subMenuDefinition.subMenu.push(button); - }); - - toolBarDefinitions.push(subMenuDefinition); - } else { + tools && + tools.forEach(element => { const button = this.buttons[element]; - toolBarDefinitions.push(button); - } - }); + toolBarDefinitions.tools.push(button); + }); + + moreTools && + moreTools.forEach(element => { + const button = this.buttons[element]; + + toolBarDefinitions.moreTools.push(button); + }); toolBarLayout.push(toolBarDefinitions); }); + console.log(`TOOLBAR LAYOUT`); console.log(toolBarLayout); - setToolBarLayout(toolBarLayout); + this.viewModelContextSetToolBarLayout(toolBarLayout); } }