Skip to content

Commit

Permalink
Update viewport state after moving the stack (#1645)
Browse files Browse the repository at this point in the history
* Update viewport state after moving the stack

* Only trigger new imagecallback if index bigger than 0

* Fix cornerstone viewport version

Co-authored-by: James Petts <[email protected]>
  • Loading branch information
igoroctaviano and JamesAPetts authored May 4, 2020
1 parent 77a421c commit 2a66e17
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion extensions/cornerstone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@
"classnames": "^2.2.6",
"lodash.merge": "^4.6.2",
"lodash.throttle": "^4.1.1",
"react-cornerstone-viewport": "^2.3.6"
"react-cornerstone-viewport": "2.3.8"
}
}
17 changes: 16 additions & 1 deletion extensions/cornerstone/src/OHIFCornerstoneViewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ConnectedCornerstoneViewport from './ConnectedCornerstoneViewport';
import OHIF from '@ohif/core';
import PropTypes from 'prop-types';
import cornerstone from 'cornerstone-core';
import debounce from 'lodash.debounce';

const { StackManager } = OHIF.utils;

Expand Down Expand Up @@ -179,7 +180,7 @@ class OHIFCornerstoneViewport extends Component {

if (
displaySet.displaySetInstanceUID !==
prevDisplaySet.displaySetInstanceUID ||
prevDisplaySet.displaySetInstanceUID ||
displaySet.SOPInstanceUID !== prevDisplaySet.SOPInstanceUID ||
displaySet.frameIndex !== prevDisplaySet.frameIndex
) {
Expand Down Expand Up @@ -215,12 +216,26 @@ class OHIFCornerstoneViewport extends Component {
});
}

const debouncedNewImageHandler = debounce(({ currentImageIdIndex, sopInstanceUid }) => {
const { displaySet } = this.props.viewportData;
const { StudyInstanceUID } = displaySet;
if (currentImageIdIndex > 0) {
this.props.onNewImage({
StudyInstanceUID,
SOPInstanceUID: sopInstanceUid,
frameIndex: currentImageIdIndex,
activeViewportIndex: viewportIndex,
});
}
}, 700);

return (
<>
<ConnectedCornerstoneViewport
viewportIndex={viewportIndex}
imageIds={imageIds}
imageIdIndex={currentImageIdIndex}
onNewImage={debouncedNewImageHandler}
// ~~ Connected (From REDUX)
// frameRate={frameRate}
// isPlaying={false}
Expand Down
11 changes: 9 additions & 2 deletions extensions/cornerstone/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,15 @@ export default {
preRegistration({ servicesManager, configuration = {} }) {
init({ servicesManager, configuration });
},
getViewportModule() {
return OHIFCornerstoneViewport;
getViewportModule({ commandsManager }) {
const ExtendedOHIFCornerstoneViewport = props => {
const onNewImageHandler = jumpData => {
commandsManager.runCommand('jumpToImage', jumpData);
};
return <OHIFCornerstoneViewport {...props} onNewImage={onNewImageHandler} />;
};

return ExtendedOHIFCornerstoneViewport;
},
getToolbarModule() {
return toolbarModule;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15598,10 +15598,10 @@ react-codemirror2@^6.0.0:
resolved "https://registry.yarnpkg.com/react-codemirror2/-/react-codemirror2-6.0.0.tgz#180065df57a64026026cde569a9708fdf7656525"
integrity sha512-D7y9qZ05FbUh9blqECaJMdDwKluQiO3A9xB+fssd5jKM7YAXucRuEOlX32mJQumUvHUkHRHqXIPBjm6g0FW0Ag==

react-cornerstone-viewport@^2.3.6:
version "2.3.6"
resolved "https://registry.yarnpkg.com/react-cornerstone-viewport/-/react-cornerstone-viewport-2.3.6.tgz#1c76bd37c95284254767296952845bacd3b810a4"
integrity sha512-MBs1Mgl0g0YswkhgoaYlaPoPDVs/HZQ3Z89thHxVytvJsgnQvhc3YrR48iRaUfQj0eYoazh7AL/lLCfd8veFKA==
react-cornerstone-viewport@^2.3.8:
version "2.3.8"
resolved "https://registry.yarnpkg.com/react-cornerstone-viewport/-/react-cornerstone-viewport-2.3.8.tgz#7af8360f29bca986ae4e36b4e503269b88ddc52f"
integrity sha512-aiG2uVNrDY6SQx4t/HBxIA3zsMsCwT+6TpcXK9qSSoXhs+X6OTmYEKncWUqL0jtxU1yfh6JTUz8ARTg03gtF+A==
dependencies:
classnames "^2.2.6"
date-fns "^2.2.1"
Expand Down

0 comments on commit 2a66e17

Please sign in to comment.