forked from OHIF/Viewers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 🐛 1241: Make Plugin switch part of ToolbarModule (OHIF#1322)
* fix: 🐛 Make Plugin switch part of ToolbarModule Closes: OHIF#1241 * Move setCornerstoneViewport command into cornerstone extension * Exposing extensionManager into extension's get modules functions * Remove Plugin switch * Updating set cornerstonelayout to work on VIEWER context * Creating a customComponent for 2D MPR button * Use extensionManager to show or not buttons Adding isHidden option into toolbarModules * Make buttons hidden depending on extension registration * Fix unit test after changes on extensionManager * Remove workaround for extensionManager * Use studyMeatadataManager and remove TODO's * Remove storeContext not needed * Moving Exit 2D MPR into cornerstone extension with VTK context * Remove PluginSwitch files * Fix E2E tests * Adding cypress screenshots into gitignore * Remove extensionManager from getModuleFn functions and moving CustomComponent for VTK button to VTK extension Co-authored-by: Danny Brown <[email protected]>
- Loading branch information
Showing
12 changed files
with
143 additions
and
185 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 |
---|---|---|
|
@@ -30,6 +30,7 @@ docker/dcm4che/dcm4che-arc | |
|
||
# Cypress test results | ||
videos/ | ||
screenshots/ | ||
|
||
# Locize settings | ||
.locize |
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,22 @@ | ||
import { redux } from '@ohif/core'; | ||
|
||
const { setLayout } = redux.actions; | ||
|
||
/** | ||
* Update the current layout with a simple Cornerstone one | ||
* | ||
* @return void | ||
*/ | ||
const setCornerstoneLayout = () => { | ||
const layout = { | ||
numRows: 1, | ||
numColumns: 1, | ||
viewports: [{ plugin: 'cornerstone' }], | ||
}; | ||
|
||
const action = setLayout(layout); | ||
|
||
window.store.dispatch(action); | ||
} | ||
|
||
export default setCornerstoneLayout; |
87 changes: 87 additions & 0 deletions
87
extensions/vtk/src/toolbarComponents/VTKMPRToolbarButton.js
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,87 @@ | ||
import React from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
import { ToolbarButton } from '@ohif/ui'; | ||
import { utils } from '@ohif/core'; | ||
|
||
const { studyMetadataManager } = utils; | ||
|
||
let isVisible = true; | ||
|
||
const _isDisplaySetReconstructable = (viewportSpecificData = {}, activeViewportIndex) => { | ||
if (!viewportSpecificData[activeViewportIndex]) { | ||
return false; | ||
}; | ||
|
||
const { displaySetInstanceUid, studyInstanceUid } = viewportSpecificData[ | ||
activeViewportIndex | ||
]; | ||
|
||
const studies = studyMetadataManager.all(); | ||
|
||
const study = studies.find( | ||
study => study.studyInstanceUID === studyInstanceUid | ||
); | ||
|
||
if (!study) { | ||
return false; | ||
} | ||
|
||
const displaySet = study._displaySets.find(set => set.displaySetInstanceUid === displaySetInstanceUid); | ||
|
||
if (!displaySet) { | ||
return false; | ||
}; | ||
|
||
return displaySet.isReconstructable; | ||
}; | ||
|
||
function VTKMPRToolbarButton({ | ||
parentContext, | ||
toolbarClickCallback, | ||
button, | ||
activeButtons, | ||
isActive, | ||
className, | ||
}) { | ||
const { id, label, icon } = button; | ||
const { viewportSpecificData, activeViewportIndex } = useSelector(state => { | ||
const { viewports = {} } = state; | ||
const { viewportSpecificData, activeViewportIndex } = viewports; | ||
|
||
return { | ||
viewportSpecificData, | ||
activeViewportIndex, | ||
} | ||
}); | ||
|
||
isVisible = _isDisplaySetReconstructable( | ||
viewportSpecificData, | ||
activeViewportIndex, | ||
); | ||
|
||
return ( | ||
<React.Fragment> | ||
{isVisible && ( | ||
<ToolbarButton | ||
key={id} | ||
label={label} | ||
icon={icon} | ||
onClick={evt => toolbarClickCallback(button, evt)} | ||
isActive={isActive} | ||
/> | ||
)} | ||
</React.Fragment> | ||
); | ||
} | ||
|
||
VTKMPRToolbarButton.propTypes = { | ||
parentContext: PropTypes.object.isRequired, | ||
toolbarClickCallback: PropTypes.func.isRequired, | ||
button: PropTypes.object.isRequired, | ||
activeButtons: PropTypes.array.isRequired, | ||
isActive: PropTypes.bool, | ||
className: PropTypes.string, | ||
}; | ||
|
||
export default VTKMPRToolbarButton; |
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
72 changes: 0 additions & 72 deletions
72
platform/viewer/src/connectedComponents/ConnectedPluginSwitch.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
106 changes: 0 additions & 106 deletions
106
platform/viewer/src/connectedComponents/PluginSwitch.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.