diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index d4cdcf5356..fa39be36db 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -12,6 +12,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released ### Added - When exploring remote URIs pasted from Neuroglancer, the format prefixes like `precomputed://` are now ignored, so users don’t have to remove them. [#8195](https://github.com/scalableminds/webknossos/pull/8195) +- Added the total volume of a dataset to a tooltip in the dataset info tab. [#8229](https://github.com/scalableminds/webknossos/pull/8229) ### Changed - Renamed "resolution" to "magnification" in more places within the codebase, including local variables. [#8168](https://github.com/scalableminds/webknossos/pull/8168) diff --git a/frontend/javascripts/libs/format_utils.ts b/frontend/javascripts/libs/format_utils.ts index e56f0e1a28..9b29e05edb 100644 --- a/frontend/javascripts/libs/format_utils.ts +++ b/frontend/javascripts/libs/format_utils.ts @@ -513,9 +513,12 @@ export function formatBytes(nbytes: number) { } export function formatVoxels(voxelCount: number) { - if (voxelCount == null || !Number.isFinite(voxelCount)) { + if (voxelCount == null) { return ""; } + if (!Number.isFinite(voxelCount)) { + return "Infinity"; + } if (voxelCount > 2 ** 50) { return `${(voxelCount / 2 ** 50).toPrecision(4)} PVx`; } diff --git a/frontend/javascripts/oxalis/model/accessors/dataset_accessor.ts b/frontend/javascripts/oxalis/model/accessors/dataset_accessor.ts index 282d14a1e3..90fac26ea8 100644 --- a/frontend/javascripts/oxalis/model/accessors/dataset_accessor.ts +++ b/frontend/javascripts/oxalis/model/accessors/dataset_accessor.ts @@ -346,6 +346,19 @@ export function getDatasetExtentAsString( formatNumberToLength(length, LongUnitToShortUnitMap[dataset.dataSource.scale.unit]), ); } +function getDatasetExtentAsProduct(extent: { + width: number; + height: number; + depth: number; +}) { + return extent.width * extent.height * extent.depth; +} +export function getDatasetExtentInVoxelAsProduct(dataset: APIDataset) { + return getDatasetExtentAsProduct(getDatasetExtentInVoxel(dataset)); +} +export function getDatasetExtentInUnitAsProduct(dataset: APIDataset) { + return getDatasetExtentAsProduct(getDatasetExtentInUnit(dataset)); +} export function determineAllowedModes(settings?: Settings): { preferredMode: APIAllowedMode | null | undefined; allowedModes: Array; diff --git a/frontend/javascripts/oxalis/view/right-border-tabs/dataset_info_tab_view.tsx b/frontend/javascripts/oxalis/view/right-border-tabs/dataset_info_tab_view.tsx index 254d554808..f9e09e57d8 100644 --- a/frontend/javascripts/oxalis/view/right-border-tabs/dataset_info_tab_view.tsx +++ b/frontend/javascripts/oxalis/view/right-border-tabs/dataset_info_tab_view.tsx @@ -6,10 +6,12 @@ import Markdown from "libs/markdown_adapter"; import React, { type CSSProperties } from "react"; import { Link } from "react-router-dom"; import type { APIDataset, APIUser } from "types/api_flow_types"; -import { ControlModeEnum } from "oxalis/constants"; -import { formatScale } from "libs/format_utils"; +import { ControlModeEnum, LongUnitToShortUnitMap } from "oxalis/constants"; +import { formatNumberToVolume, formatScale, formatVoxels } from "libs/format_utils"; import { getDatasetExtentAsString, + getDatasetExtentInUnitAsProduct, + getDatasetExtentInVoxelAsProduct, getMagnificationUnion, getReadableURLPart, } from "oxalis/model/accessors/dataset_accessor"; @@ -127,9 +129,27 @@ const shortcuts = [ export function DatasetExtentRow({ dataset }: { dataset: APIDataset }) { const extentInVoxel = getDatasetExtentAsString(dataset, true); const extentInLength = getDatasetExtentAsString(dataset, false); + const extentProductInVx = getDatasetExtentInVoxelAsProduct(dataset); + const extentProductInUnit = getDatasetExtentInUnitAsProduct(dataset); + const formattedExtentInUnit = formatNumberToVolume( + extentProductInUnit, + LongUnitToShortUnitMap[dataset.dataSource.scale.unit], + ); + + const renderDSExtentTooltip = () => { + return ( +
+ Dataset extent: +
+ {formatVoxels(extentProductInVx)} +
+ {formattedExtentInUnit} +
+ ); + }; return ( - +