Skip to content

Commit

Permalink
feat: initial viewport settings can be utilized (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
sedghi authored Jun 11, 2021
1 parent f0b2815 commit a29c466
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/CornerstoneViewport/CornerstoneViewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class CornerstoneViewport extends Component {
isPlaying: PropTypes.bool,
frameRate: PropTypes.number, // Between 1 and ?
//
initialViewport: PropTypes.object,
setViewportActive: PropTypes.func, // Called when viewport should be set to active?
onNewImage: PropTypes.func,
onNewImageDebounced: PropTypes.func,
Expand Down Expand Up @@ -91,6 +92,7 @@ class CornerstoneViewport extends Component {
cineFrameRate: 24,
viewportOverlayComponent: ViewportOverlay,
imageIds: ['no-id://'],
initialViewport: {},
// Init
cornerstoneOptions: {},
isStackPrefetchEnabled: false,
Expand Down Expand Up @@ -151,6 +153,7 @@ class CornerstoneViewport extends Component {
imageIds,
isPlaying,
frameRate,
initialViewport,
} = this.props;
const { imageIdIndex } = this.state;
const imageId = imageIds[imageIdIndex];
Expand Down Expand Up @@ -187,7 +190,7 @@ class CornerstoneViewport extends Component {

// Display

cornerstone.displayImage(this.element, image);
cornerstone.displayImage(this.element, image, initialViewport);

if (isStackPrefetchEnabled) {
cornerstoneTools.stackPrefetch.enable(this.element);
Expand All @@ -212,6 +215,7 @@ class CornerstoneViewport extends Component {
imageIds: stack,
imageIdIndex: imageIndex,
isStackPrefetchEnabled,
initialViewport,
} = this.props;
const {
imageIds: prevStack,
Expand Down Expand Up @@ -241,7 +245,7 @@ class CornerstoneViewport extends Component {
cornerstoneTools.stopClip(this.element);
const image = await cornerstone.loadAndCacheImage(imageId);

cornerstone.displayImage(this.element, image);
cornerstone.displayImage(this.element, image, initialViewport);
cornerstone.reset(this.element);
} catch (err) {
// :wave:
Expand Down

0 comments on commit a29c466

Please sign in to comment.