Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

state of CornerstoneViewport does not update #117

Open
aamirsahmad opened this issue Mar 31, 2021 · 2 comments · May be fixed by #126
Open

state of CornerstoneViewport does not update #117

aamirsahmad opened this issue Mar 31, 2021 · 2 comments · May be fixed by #126

Comments

@aamirsahmad
Copy link

If the state is updated (tools or imageIds) from the parent object, React does not re-render the CornerstoneViewport component to reflect the changes.

A common use case is to use the Pan tool and Length tool with both bound to the left mouse button. This can be achieved with a toggle button that updates the state by making Pan Tool's status be passive and Length Tool's status to be active. Currently, this is not possible as the state of CornerstoneViewport does not gets updated.

state = {
  tools: [
    // Mouse
    {
      name: 'Wwwc',
      mode: 'active',
      modeOptions: { mouseButtonMask: 1 },
    },
    {
      name: 'Zoom',
      mode: 'active',
      modeOptions: { mouseButtonMask: 2 },
    },
    {
      name: 'Pan',
      mode: 'active',
      modeOptions: { mouseButtonMask: 4 },
    },
    // Scroll
    { name: 'StackScrollMouseWheel', mode: 'active' },
    // Touch
    { name: 'PanMultiTouch', mode: 'active' },
    { name: 'ZoomTouchPinch', mode: 'active' },
    { name: 'StackScrollMultiTouch', mode: 'active' },
  ],
  imageIds: [
    'dicomweb://s3.amazonaws.com/lury/PTCTStudy/1.3.6.1.4.1.25403.52237031786.3872.20100510032220.11.dcm',
    'dicomweb://s3.amazonaws.com/lury/PTCTStudy/1.3.6.1.4.1.25403.52237031786.3872.20100510032220.12.dcm',
  ],
};

{/* RENDER */}
<CornerstoneViewport
  tools={this.state.tools}
  imageIds={this.state.imageIds}
  style={{ minWidth: '100%', height: '512px', flex: '1' }}
/>

This can be reproduced at https://react.cornerstonejs.org/basic
Change the state of ExamplePageBasic using the React Developer Tools in Chrome.

@aamirsahmad aamirsahmad changed the title state of CornerstoneViewport does not get updated state of CornerstoneViewport does not update Mar 31, 2021
@coderdecoder
Copy link

Any updates on this or a direction to look in? I'm having the same issue.

@burnpiro
Copy link
Contributor

The current version of the Viewer does not support updates of tools prop. Once you've set them when initializing the component they are unchanged during the component's lifecycle. The only thing you can do is to change activeTool and/or frameRate, isPlaying, isOverlayVisible props. That and the imageId stack ofc. The rest is not even in the update lifecycle.

burnpiro added a commit to burnpiro/react-cornerstone-viewport that referenced this issue Sep 28, 2021
… changed. Call executes on every update and updates the state of all provided tools. This allows to turn tools ON/OFF without initializing entire `CornerstoneViewport` component.

Resolves cornerstonejs#117
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants