setLayout not work

Describe Your Question

  • When I use setLayout change my grid,I get an error.
  • version v3-stable

What steps can we follow to reproduce the bug?

in modes/longitudinal/src/index.js onModeEnter:

const studySub = DicomMetadataStore.subscribe(
        (data) => {
          const study = DicomMetadataStore.getStudy(data.StudyInstanceUID);
          const layoutSub = HangingProtocolService.subscribe(
            () => {
              if (['CT', 'MR'].includes(study.ModalitiesInStudy[0])) {
                // 实现有bug
                viewportGridService.setLayout({ numCols: 2, numRows: 2 });

I haven’t the findOrCreateViewport function.

Thank you for your question. Indeed the setLayout method changed recently. There is a findOrCreateViewport function in extensions\default\src\findViewportsByPosition.ts that you might be able to use. For an example of how it could be used, see the code for the default “change layout UI” command in extensions\default\src\commandsModule.ts in the command setViewportGridLayout.

I hope this helps.

1 Like

Nice, I use commandsManager.runCommand instead of setLayout, my program is running right now. :smile:

Thanks for your help.