fix: disable seg download/export buttons until a user has drawn something (#4953)
This commit is contained in:
parent
dd2e89bfdb
commit
7ffe17deea
@ -108,6 +108,7 @@ export const CustomDropdownMenuContent = () => {
|
||||
e.preventDefault();
|
||||
actions.downloadCSVSegmentationReport(segmentationId);
|
||||
}}
|
||||
disabled={!allowExport}
|
||||
>
|
||||
{t('CSV Report')}
|
||||
</DropdownMenuItem>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { SegmentationTable } from '@ohif/ui-next';
|
||||
import { useActiveViewportSegmentationRepresentations } from '../hooks/useActiveViewportSegmentationRepresentations';
|
||||
import { metaData } from '@cornerstonejs/core';
|
||||
import { metaData, cache } from '@cornerstonejs/core';
|
||||
import { useSystem } from '@ohif/core/src';
|
||||
|
||||
export default function PanelSegmentation({ children }: withAppTypes) {
|
||||
@ -104,6 +104,26 @@ export default function PanelSegmentation({ children }: withAppTypes) {
|
||||
return { segmentationId, isExportable: true };
|
||||
}
|
||||
|
||||
// Check if any segments have anything drawn in any of the viewports
|
||||
const hasAnySegmentData = (() => {
|
||||
const imageIds = Labelmap.imageIds;
|
||||
if (!imageIds?.length) return false;
|
||||
|
||||
for (const imageId of imageIds) {
|
||||
const pixelData = cache.getImage(imageId)?.getPixelData();
|
||||
if (!pixelData) continue;
|
||||
|
||||
for (let i = 0; i < pixelData.length; i++) {
|
||||
if (pixelData[i] !== 0) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
})();
|
||||
|
||||
if (!hasAnySegmentData) {
|
||||
return { segmentationId, isExportable: false };
|
||||
}
|
||||
|
||||
const referencedImageIds = Labelmap.referencedImageIds;
|
||||
const firstImageId = referencedImageIds[0];
|
||||
const instance = metaData.get('instance', firstImageId);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user