Skip to content

Commit

Permalink
Merge branch 'master' into rename-resolution-to-mag-localvars
Browse files Browse the repository at this point in the history
  • Loading branch information
knollengewaechs authored Dec 2, 2024
2 parents 3b75011 + 3b00409 commit f0e10b1
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion frontend/javascripts/libs/format_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
}
Expand Down
13 changes: 13 additions & 0 deletions frontend/javascripts/oxalis/model/accessors/dataset_accessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<APIAllowedMode>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 (
<div>
Dataset extent:
<br />
{formatVoxels(extentProductInVx)}
<br />
{formattedExtentInUnit}
</div>
);
};

return (
<FastTooltip title="Dataset extent" placement="left" wrapper="tr">
<FastTooltip dynamicRenderer={renderDSExtentTooltip} placement="left" wrapper="tr">
<td
style={{
paddingRight: 20,
Expand Down

0 comments on commit f0e10b1

Please sign in to comment.