Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
74f8f3e
wip
philippotto Oct 6, 2025
5ee1c8f
clean up
philippotto Oct 27, 2025
52da095
rename volume layer to section labeler
philippotto Oct 27, 2025
5bfa780
rename section labeling module
philippotto Oct 27, 2025
adc5b63
update comment
philippotto Oct 27, 2025
1cce98f
more private methods
philippotto Oct 27, 2025
756fe62
refactor fast/non-fast 3d coordinate functions in section labeling
philippotto Oct 27, 2025
dc237b9
move get3DCoordinateFromLocal2D into voxel buffer and add getTopLeft3…
philippotto Oct 27, 2025
98fbefe
implement wip for TransformedSectionLabeler
philippotto Oct 27, 2025
3369292
rename addToLayer
philippotto Oct 28, 2025
0680b2d
adapt plane to rotation
philippotto Oct 28, 2025
104c0d7
fix annotation contour in transformed layer
philippotto Oct 28, 2025
b573f93
format
philippotto Oct 28, 2025
ae6d11b
use adapted plane when applying voxel buffer
philippotto Oct 28, 2025
ec73778
refactor; hardcode transformed plane; fix brush scaling; add debug ou…
philippotto Nov 3, 2025
4851335
add and fix tests
philippotto Nov 5, 2025
4efe594
clean up
philippotto Nov 6, 2025
b37dc7f
clean up
philippotto Nov 6, 2025
9d78d13
fix tests
philippotto Nov 6, 2025
346ae66
disable annotation for rotated layers again
philippotto Nov 6, 2025
42431fa
more clean up
philippotto Nov 6, 2025
e958267
add missing import
philippotto Nov 6, 2025
b92cd53
format
philippotto Nov 6, 2025
e816c6f
remove layer pos from status bar again
philippotto Nov 6, 2025
520ca70
remove more console.logs
philippotto Nov 6, 2025
c624d9b
remove import
philippotto Nov 6, 2025
227bc61
clean up
philippotto Nov 6, 2025
204d929
refactor
philippotto Nov 6, 2025
668d77b
fix tests
philippotto Nov 7, 2025
60992be
incorporate some feedback
philippotto Nov 10, 2025
0cbd82e
fix layer vs world space
philippotto Nov 10, 2025
ee102fe
misc
philippotto Nov 10, 2025
0fb28a6
format
philippotto Nov 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Col, Form, type FormInstance, InputNumber, Row, Slider, Tooltip, Typogr
import FormItem from "antd/es/form/FormItem";
import Checkbox, { type CheckboxChangeEvent } from "antd/lib/checkbox/Checkbox";
import { useCallback, useEffect, useMemo } from "react";
import type { APIDataLayer } from "types/api_types";
import type { APIDataLayer, AffineTransformation } from "types/api_types";
import {
AXIS_TO_TRANSFORM_INDEX,
EXPECTED_TRANSFORMATION_LENGTH,
Expand Down Expand Up @@ -64,13 +64,7 @@ export const AxisRotationFormItem: React.FC<AxisRotationFormItemProps> = ({
y: RotationAndMirroringSettings;
z: RotationAndMirroringSettings;
} = form.getFieldValue(["datasetRotation"]);
const transformations = [
fromCenterToOrigin(datasetBoundingBox),
getRotationMatrixAroundAxis("x", rotationValues["x"]),
getRotationMatrixAroundAxis("y", rotationValues["y"]),
getRotationMatrixAroundAxis("z", rotationValues["z"]),
fromOriginToCenter(datasetBoundingBox),
];
const transformations = getRotationalTransformation(datasetBoundingBox, rotationValues);
const dataLayersWithUpdatedTransforms = dataLayers.map((layer) => {
return {
...layer,
Expand Down Expand Up @@ -227,3 +221,20 @@ export const AxisRotationSettingForDataset: React.FC<AxisRotationSettingForDatas
</div>
);
};

export function getRotationalTransformation(
datasetBoundingBox: BoundingBox,
rotationValues: {
x: RotationAndMirroringSettings;
y: RotationAndMirroringSettings;
z: RotationAndMirroringSettings;
},
): AffineTransformation[] {
return [
fromCenterToOrigin(datasetBoundingBox),
getRotationMatrixAroundAxis("x", rotationValues["x"]),
getRotationMatrixAroundAxis("y", rotationValues["y"]),
getRotationMatrixAroundAxis("z", rotationValues["z"]),
fromOriginToCenter(datasetBoundingBox),
];
}
65 changes: 8 additions & 57 deletions frontend/javascripts/libs/drawing.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import type { Vector3 } from "viewer/constants";
type RangeItem = [number, number, number, boolean | null, boolean, boolean];

// This is a class with static methods and constants dealing with drawing
// lines and filling polygons
// Macros
// Constants
const SMOOTH_LENGTH = 4;
const SMOOTH_ALPHA = 0.2;
// lines and filling polygons.

class Drawing {
alpha: number = SMOOTH_ALPHA;
smoothLength: number = SMOOTH_LENGTH;

drawHorizontalLine2d(
private drawHorizontalLine2d(
y: number,
x1: number,
x2: number,
Expand Down Expand Up @@ -91,7 +84,7 @@ class Drawing {
}
}

addNextLine(
private addNextLine(
newY: number,
isNext: boolean,
downwards: boolean,
Expand Down Expand Up @@ -135,7 +128,7 @@ class Drawing {
}
}

paintBorder(
private paintBorder(
x1: number,
y1: number,
x2: number,
Expand Down Expand Up @@ -212,19 +205,15 @@ class Drawing {

while (ranges.length) {
const r = ranges.pop();
// @ts-expect-error ts-migrate(2532) FIXME: Object is possibly 'undefined'.
if (r == null) {
throw new Error("Array is expected to be not empty.");
}
let minX = r[0];
// @ts-expect-error ts-migrate(2532) FIXME: Object is possibly 'undefined'.
let maxX = r[1];
// @ts-expect-error ts-migrate(2532) FIXME: Object is possibly 'undefined'.
y = r[2];
// @ts-expect-error ts-migrate(2532) FIXME: Object is possibly 'undefined'.
const down = r[3] === true;
// @ts-expect-error ts-migrate(2532) FIXME: Object is possibly 'undefined'.
const up = r[3] === false;
// @ts-expect-error ts-migrate(2532) FIXME: Object is possibly 'undefined'.
const extendLeft = r[4];
// @ts-expect-error ts-migrate(2532) FIXME: Object is possibly 'undefined'.
const extendRight = r[5];

if (extendLeft) {
Expand All @@ -250,19 +239,15 @@ class Drawing {
maxX++;
}
} else {
// @ts-expect-error ts-migrate(2532) FIXME: Object is possibly 'undefined'.
r[0]--;
// @ts-expect-error ts-migrate(2532) FIXME: Object is possibly 'undefined'.
r[1]++;
}

if (y < height) {
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'RangeItem | undefined' is not as... Remove this comment to see the full error message
this.addNextLine(y + 1, !up, true, minX, maxX, r, ranges, test, paint);
}

if (y > 0) {
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'RangeItem | undefined' is not as... Remove this comment to see the full error message
this.addNextLine(y - 1, !down, false, minX, maxX, r, ranges, test, paint);
}
}
Expand All @@ -288,40 +273,6 @@ class Drawing {
}
}
}

// Source : http://twistedoakstudios.com/blog/Post3138_mouse-path-smoothing-for-jack-lumber
smoothLine(points: Array<Vector3>, callback: (arg0: Vector3) => void): Array<Vector3> {
const smoothLength = this.smoothLength || SMOOTH_LENGTH;
const a = this.alpha || SMOOTH_ALPHA;

if (points.length > 2 + smoothLength) {
for (let i = 0; i < smoothLength; i++) {
const j = points.length - i - 2;
const p0 = points[j];
const p1 = points[j + 1];
const p = [0, 0, 0];

for (let k = 0; k < 3; k++) {
p[k] = p0[k] * (1 - a) + p1[k] * a;
}

// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'number[]' is not assignable to p... Remove this comment to see the full error message
callback(p);
// @ts-expect-error ts-migrate(2322) FIXME: Type 'number[]' is not assignable to type 'Vector3... Remove this comment to see the full error message
points[j] = p;
}
}

return points;
}

setSmoothLength(v: number): void {
this.smoothLength = v;
}

setAlpha(v: number): void {
this.alpha = v;
}
}

export default new Drawing();
3 changes: 3 additions & 0 deletions frontend/javascripts/test/global_mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ vi.mock("antd", () => {
Form: {
Item: {},
},
Typography: {
Text: {},
},
};
});

Expand Down
Loading