OHIF / Viewers

OHIF zero-footprint DICOM viewer and oncology specific Lesion Tracker, plus shared extension packages
https://docs.ohif.org/
MIT License
3.1k stars 3.28k forks source link

Command "mpr2d" not found in current context #1240

Closed khanhphamqn closed 4 years ago

khanhphamqn commented 4 years ago

Bug Report

Command "mpr2d" not found in current context

Describe the Bug

This issue works well on develop but when using yarn build:package to build production it will appear

What steps can we follow to reproduce the bug?

  1. Run the web
  2. Select the patient with name LIDC-IDRI-0314
  3. it will navigate to the relative path viewer/1.3.6.1.4.1.14519.5.2.1.6279.6001.265704884949271879044145982159 click on button 2D MPR and vtk does not work. Opening the develop tools and we will see this issue like below image

issue

dannyrb commented 4 years ago

The PWA build includes all extensions in the monorepo by default. You can see them listed in platform/viewer/src/index.js.

When you use yarn run build:package, you're creating separate bundles for the "Viewer" platform, and for each extension. Each extension bundle needs to be manually included, and then listed in the application's extensions configuration. You can see an example of this flow in this code sandbox: https://codesandbox.io/s/viewer-script-tag-microscopy-extension-44unk

  <body>
    <div id="root"></div>

    <script src="https://unpkg.com/@ohif/viewer@1.1.10/dist/index.umd.js"></script>
    <script src="https://unpkg.com/@ohif/extension-dicom-microscopy@0.50.0/dist/index.umd.js"></script>

    <script>
      var containerId = "root";
      var componentRenderedOrUpdatedCallback = function() {
        console.log("OHIF Viewer rendered/updated");
      };
      window.OHIFViewer.installViewer(
        {
          servers: {
            dicomWeb: [/* server config */]
          },
          extensions: [OHIFExtDicomMicroscopy]
        },
        containerId,
        componentRenderedOrUpdatedCallback
      );
    </script>
  </body>

If you're already building the application after making changes, I recommend using yarn run build and tweaking the entrypoint to meet your needs.

dannyrb commented 4 years ago

I did create a related issue from your report. The 2D MPR button should not show unless the VTK Extension is registered. It looks like we currently have it "hard coded" into the Viewer project (part of the core platform)

See: https://github.com/OHIF/Viewers/issues/1241

khanhphamqn commented 4 years ago

@dannyrb Thanks for your helpful information. As far as I know the defauft config will be in folder platform/viewer/public/config/default.js.

Is it possible if I would like to add all extensions in this file such OHIFVTKExtension, OHIFDicomHtmlExtension OHIFDicomMicroscopyExtension OHIFDicomPDFExtension.

Actually, I followed the code in platform/viewer/src/index.js and applied it into the file platform/viewer/src/App.js and it works well when using yarn build:package. But I think it is so risky or something like that. That's why I would like to ask.

I would appreciate if you could help me.

dannyrb commented 4 years ago

Actually, I followed the code in platform/viewer/src/index.js and applied it into the file platform/viewer/src/App.js and it works well when using yarn build:package. But I think it is so risky or something like that. That's why I would like to ask.

This would do the trick. It would include all of the extensions in the created @ohif/viewer package. I'm still unsure of why you're using this approach instead of the PWA (yarn run build).

It's not risky, it's just sub-optimal.

khanhphamqn commented 4 years ago

@dannyrb . I really appreciate your help. I did use yarn run build command but this command created a bunch of files. it looks like below image

build

That's why I used above approach instead of yarn run build

dannyrb commented 4 years ago

How are you trying to deploy/host the application? The fact that there are more files provides an advantage. The application is able to load/render much faster, and as other portions of the application are required, their (much smaller) files are requested. There are other advantages, but that's at least a little insight into why there are more files.

I would normally recommend using the packaged version for simple demonstrations, or if you only need basic 2D viewing.

At the end of the day, both can work. Choose whatever works best for you ^_^ Both setups can work if configured correctly.

khanhphamqn commented 4 years ago

@dannyrb Thank you so much for your help. I think I should close this issue