How to use the cornerstone-core.getViewport function in cornerstone-core

To help you get started, we’ve selected a few cornerstone-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OHIF / ohif-core / src / measurements / measurementHandlers / handleChildMeasurementModified.js View on Github external
const collection = measurementApi.tools[tool.parentTool];

  // Stop here if the tool data shall not be persisted (e.g. temp tools)
  if (!collection) return;

  log.info('CornerstoneToolsMeasurementModified');

  const measurement = collection.find(t => t._id === measurementData._id);
  let childMeasurement = measurement && measurement[tool.attribute];

  // Stop here if the measurement is already deleted
  if (!childMeasurement) return;

  childMeasurement = Object.assign(childMeasurement, measurementData);
  childMeasurement.viewport = cornerstone.getViewport(eventData.element);

  // Update the parent measurement
  measurement[tool.attribute] = childMeasurement;
  measurementApi.updateMeasurement(tool.parentTool, measurement);

  // TODO: Notify about the last activated measurement

  if (MeasurementApi.isToolIncluded(tool)) {
    // TODO: Notify that viewer suffered changes
  }
}
github OHIF / ohif-core / src / measurements / measurementHandlers / handleSingleMeasurementModified.js View on Github external
const { measurementData, toolType } = eventData;

  const collection = measurementApi.tools[toolType];

  // Stop here if the tool data shall not be persisted (e.g. temp tools)
  if (!collection) return;

  log.info('CornerstoneToolsMeasurementModified');
  let measurement = collection.find(t => t._id === measurementData._id);

  // Stop here if the measurement is already deleted
  if (!measurement) return;

  measurement = Object.assign(measurement, measurementData);
  measurement.viewport = cornerstone.getViewport(eventData.element);

  measurementApi.updateMeasurement(toolType, measurement);

  // TODO: Notify about the last activated measurement

  if (MeasurementApi.isToolIncluded(tool)) {
    // TODO: Notify that viewer suffered changes
  }
}
github PulseTile / PulseTile-React-Core / src / components / pages / Images / ImagesDetail / ImagesDetail.js View on Github external
zoomout = /* istanbul ignore next */ () => {
    const cornerstoneElement = this.getImgBlock();
    const viewport = cornerstone.getViewport(cornerstoneElement);
    if (viewport.scale > 0.1) {
      viewport.scale -= 0.1;
      cornerstone.setViewport(cornerstoneElement, viewport);
    }
  };
github OHIF / Viewers / extensions / cornerstone / src / commandsModule.js View on Github external
invertViewport: ({ viewports }) => {
      const enabledElement = getEnabledElement(viewports.activeViewportIndex);

      if (enabledElement) {
        let viewport = cornerstone.getViewport(enabledElement);
        viewport.invert = !viewport.invert;
        cornerstone.setViewport(enabledElement, viewport);
      }
    },
    // TODO: this is receiving `evt` from `ToolbarRow`. We could use it to have
github OHIF / Viewers / extensions / cornerstone / src / commandsModule.js View on Github external
flipViewportVertical: ({ viewports }) => {
      const enabledElement = getEnabledElement(viewports.activeViewportIndex);

      if (enabledElement) {
        let viewport = cornerstone.getViewport(enabledElement);
        viewport.vflip = !viewport.vflip;
        cornerstone.setViewport(enabledElement, viewport);
      }
    },
    scaleViewport: ({ direction, viewports }) => {
github OHIF / Viewers / extensions / cornerstone / src / commandsModule.js View on Github external
scaleViewport: ({ direction, viewports }) => {
      const enabledElement = getEnabledElement(viewports.activeViewportIndex);
      const step = direction * 0.15;

      if (enabledElement) {
        if (step) {
          let viewport = cornerstone.getViewport(enabledElement);
          viewport.scale += step;
          cornerstone.setViewport(enabledElement, viewport);
        } else {
          cornerstone.fitToWindow(enabledElement);
        }
      }
    },
    resetViewport: ({ viewports }) => {
github OHIF / Viewers / extensions / cornerstone / src / commandsModule.js View on Github external
rotateViewport: ({ viewports, rotation }) => {
      const enabledElement = getEnabledElement(viewports.activeViewportIndex);

      if (enabledElement) {
        let viewport = cornerstone.getViewport(enabledElement);
        viewport.rotation += rotation;
        cornerstone.setViewport(enabledElement, viewport);
      }
    },
    flipViewportHorizontal: ({ viewports }) => {
github Kitware / paraview-glance / Sources / externals / MedicalCornerstone / CornerstoneRenderer.js View on Github external
.then((image) => {
        const viewport = Object.assign(
          {},
          cornerstone.getViewport(model.container)
        );

        if (resetViewport) {
          Object.assign(
            viewport,
            cornerstone.getDefaultViewportForImage(model.container, image)
          );
        }

        Object.assign(viewport, {
          voi: {
            windowWidth: model.representation.getColorWindow(),
            windowCenter: model.representation.getColorLevel(),
          },
          hflip: model.representation.getHFlip(),
          vflip: model.representation.getVFlip(),
github OHIF / Viewers / extensions / cornerstone / src / commandsModule.js View on Github external
flipViewportHorizontal: ({ viewports }) => {
      const enabledElement = getEnabledElement(viewports.activeViewportIndex);

      if (enabledElement) {
        let viewport = cornerstone.getViewport(enabledElement);
        viewport.hflip = !viewport.hflip;
        cornerstone.setViewport(enabledElement, viewport);
      }
    },
    flipViewportVertical: ({ viewports }) => {