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(
        DicomMetadataStore.EVENTS.SERIES_ADDED,
        (data) => {
          const study = DicomMetadataStore.getStudy(data.StudyInstanceUID);
          const layoutSub = HangingProtocolService.subscribe(
            HangingProtocolService.EVENTS.NEW_LAYOUT,
            () => {
              if (['CT', 'MR'].includes(study.ModalitiesInStudy[0])) {
                // 实现有bug
                viewportGridService.setLayout({ numCols: 2, numRows: 2 });
              }
              layoutSub.unsubscribe();
            }
          );
          studySub.unsubscribe();
        }
      );

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.