How to use the cornerstone-core.getEnabledElements 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 / handleSingleMeasurementAdded.js View on Github external
const measurement = Object.assign({}, measurementData, imageAttributes, {
    lesionNamingNumber: measurementData.lesionNamingNumber,
    userId: user.getUserId(),
    toolType,
  });

  const addedMeasurement = measurementApi.addMeasurement(toolType, measurement);
  Object.assign(measurementData, addedMeasurement);

  const measurementLabel = getLabel(measurementData);
  if (measurementLabel) {
    measurementData.labels = [measurementLabel];
  }

  // TODO: This is very hacky, but will work for now
  cornerstone.getEnabledElements().forEach(enabledElement => {
    cornerstone.updateImage(enabledElement.element);
  });

  // TODO: Notify about the last activated measurement

  if (MeasurementApi.isToolIncluded(tool)) {
    // TODO: Notify that viewer suffered changes
  }
}
github OHIF / Viewers / platform / viewer / src / appExtensions / MeasurementsPanel / ConnectedMeasurementTable.js View on Github external
});
      });

      const measurementsToActive = measurementApi.tools[toolType].filter(
        measurement => {
          return measurement.measurementNumber === measurementNumber;
        }
      );

      measurementsToActive.forEach(measurementToActive => {
        measurementToActive.active = true;
      });

      measurementApi.syncMeasurementsAndToolData();

      cornerstone.getEnabledElements().forEach(enabledElement => {
        cornerstone.updateImage(enabledElement.element);
      });

      // Needs to update viewports.layout state to set layout
      //const layout = actionData.layout;
      //dispatch(setLayout(layout))

      // Needs to update viewports.activeViewportIndex to the first updated viewport
      //const viewportIndex = actionData.viewportIndex;
      //dispatch(setViewportActive(viewportIndex));

      // Needs to update timepointsManager.measurements state to set active measurementId
      // TODO: Not yet implemented
      //dispatch(setActiveMeasurement(measurementData.measurementId))

      // (later): Needs to set some property on state.extensions.cornerstone to synchronize viewport scrolling
github OHIF / Viewers / extensions / cornerstone / src / commandsModule.js View on Github external
const measurementApi = OHIF.measurements.MeasurementApi.Instance;
      const measurements = measurementApi.tools[toolType].filter(
        m => m.measurementNumber === measurementNumber
      );

      measurements.forEach(measurement => {
        measurement.location = location;
        measurement.description = description;

        measurementApi.updateMeasurement(measurement.toolType, measurement);
      });

      measurementApi.syncMeasurementsAndToolData();

      // Update images in all active viewports
      cornerstone.getEnabledElements().forEach(enabledElement => {
        cornerstone.updateImage(enabledElement.element);
      });
    },
    showContextMenu({ event }) {
github OHIF / Viewers / platform / viewer / src / appExtensions / MeasurementsPanel / updateTableWithNewMeasurementData.js View on Github external
const measurementApi = OHIF.measurements.MeasurementApi.Instance;
  const measurements = measurementApi.tools[toolType].filter(
    m => m.measurementNumber === measurementNumber
  );

  measurements.forEach(measurement => {
    measurement.location = location;
    measurement.description = description;

    measurementApi.updateMeasurement(measurement.toolType, measurement);
  });

  measurementApi.syncMeasurementsAndToolData();

  // Update images in all active viewports
  cornerstone.getEnabledElements().forEach(enabledElement => {
    cornerstone.updateImage(enabledElement.element);
  });
}
github OHIF / ohif-core / src / measurements / measurementHandlers / handleSingleMeasurementRemoved.js View on Github external
const measurementTypeId = measurementApi.toolsGroupsMap[toolType];
  const measurement = collection.find(t => t._id === measurementData._id);

  // Stop here if the measurement is already gone or never existed
  if (!measurement) return;

  // Remove all the measurements with the given type and number
  const { lesionNamingNumber, timepointId } = measurement;
  measurementApi.deleteMeasurements(toolType, measurementTypeId, {
    lesionNamingNumber,
    timepointId,
  });

  // TODO: This is very hacky, but will work for now
  cornerstone.getEnabledElements().forEach(enabledElement => {
    cornerstone.updateImage(enabledElement.element);
  });

  if (MeasurementApi.isToolIncluded(tool)) {
    // TODO: Notify that viewer suffered changes
  }
}
github OHIF / ohif-core / src / measurements / measurementHandlers / handleChildMeasurementRemoved.js View on Github external
// Stop here if the measurement is already gone or never existed
  if (!measurement) return;

  if (measurement.childToolsCount === 1) {
    // Remove the measurement
    collection.splice(measurementIndex, 1);
    measurementApi.onMeasurementRemoved(tool.parentTool, measurement);
  } else {
    // Update the measurement
    measurement[tool.attribute] = null;
    measurement.childToolsCount = (measurement.childToolsCount || 0) - 1;
    measurementApi.updateMeasurement(tool.parentTool, measurement);
  }

  // TODO: This is very hacky, but will work for now
  cornerstone.getEnabledElements().forEach(enabledElement => {
    cornerstone.updateImage(enabledElement.element);
  });

  if (MeasurementApi.isToolIncluded(tool)) {
    // TODO: Notify that viewer suffered changes
  }
}
github OHIF / Viewers / platform / core / src / measurements / classes / MeasurementApi.js View on Github external
const measurements = measurementData[measurementTypeId];

            measurements.forEach(measurement => {
              const { toolType } = measurement;

              this.addMeasurement(toolType, measurement);
            });
          });
        }

        resolve();

        // Synchronize the new tool data
        this.syncMeasurementsAndToolData();

        cornerstone.getEnabledElements().forEach(enabledElement => {
          cornerstone.updateImage(enabledElement.element);
        });

        // Let others know that the measurements are updated
        this.onMeasurementsUpdated();
      }, reject);
    });
github OHIF / ohif-core / src / measurements / measurementHandlers / handleChildMeasurementAdded.js View on Github external
);

    const addedMeasurement = measurementApi.addMeasurement(
      tool.parentTool,
      measurement
    );
    Object.assign(measurementData, addedMeasurement);
  }

  const measurementLabel = getLabel(measurementData);
  if (measurementLabel) {
    measurementData.labels = [measurementLabel];
  }

  // TODO: This is very hacky, but will work for now
  cornerstone.getEnabledElements().forEach(enabledElement => {
    cornerstone.updateImage(enabledElement.element);
  });

  // TODO: Notify about the last activated measurement

  if (MeasurementApi.isToolIncluded(tool)) {
    // TODO: Notify that viewer suffered changes
  }
}
github OHIF / Viewers / src / lib / updateTableWithNewMeasurementData.js View on Github external
const measurementApi = OHIF.measurements.MeasurementApi.Instance;
  const measurements = measurementApi.tools[toolType].filter(
    m => m.measurementNumber === measurementNumber
  );

  measurements.forEach(measurement => {
    measurement.location = location;
    measurement.description = description;

    measurementApi.updateMeasurement(measurement.toolType, measurement);
  });

  measurementApi.syncMeasurementsAndToolData();

  // Update images in all active viewports
  cornerstone.getEnabledElements().forEach(enabledElement => {
    cornerstone.updateImage(enabledElement.element);
  });
}
github OHIF / Viewers / platform / viewer / src / appExtensions / MeasurementsPanel / ConnectedMeasurementTable.js View on Github external
dispatchEditDescription: (event, measurementData, viewportsState) => {
      event.persist();

      const activeViewportIndex =
        (viewportsState && viewportsState.activeViewportIndex) || 0;

      const enabledElements = cornerstone.getEnabledElements();
      if (!enabledElements || enabledElements.length <= activeViewportIndex) {
        OHIF.log.error('Failed to find the enabled element');
        return;
      }

      const { toolType, measurementId } = measurementData;
      const tool = MeasurementApi.Instance.tools[toolType].find(measurement => {
        return measurement._id === measurementId;
      });

      if (ownProps.onEditDescription) {
        ownProps.onEditDescription(tool);
      }
    },
    dispatchJumpToRowItem: (