|
18 | 18 | * @file Basic annotation data structures. |
19 | 19 | */ |
20 | 20 |
|
| 21 | +import { vec3 } from "gl-matrix"; |
21 | 22 | import type { |
22 | 23 | BoundingBox, |
23 | 24 | CoordinateSpaceTransform, |
@@ -695,6 +696,13 @@ export interface AnnotationTypeHandler<T extends Annotation = Annotation> { |
695 | 696 | annotation: T, |
696 | 697 | callback: (vec: Float32Array, isVector: boolean) => void, |
697 | 698 | ) => void; |
| 699 | + defaultProperties: ( |
| 700 | + annotation: T, |
| 701 | + scales: vec3, |
| 702 | + ) => { |
| 703 | + properties: AnnotationNumericPropertySpec[]; |
| 704 | + values: number[]; |
| 705 | + }; |
698 | 706 | } |
699 | 707 |
|
700 | 708 | function serializeFloatVector( |
@@ -814,6 +822,24 @@ export const annotationTypeHandlers: Record< |
814 | 822 | callback(annotation.pointA, false); |
815 | 823 | callback(annotation.pointB, false); |
816 | 824 | }, |
| 825 | + defaultProperties(annotation: Line, scales: vec3) { |
| 826 | + return { |
| 827 | + properties: [ |
| 828 | + { |
| 829 | + type: "float32", |
| 830 | + identifier: "Length", |
| 831 | + default: 0, |
| 832 | + description: "Length of the line annotation in nanometers", |
| 833 | + }, |
| 834 | + ], |
| 835 | + values: [ |
| 836 | + vec3.dist( |
| 837 | + vec3.mul(vec3.create(), scales, annotation.pointA as vec3), |
| 838 | + vec3.mul(vec3.create(), scales, annotation.pointB as vec3), |
| 839 | + ), |
| 840 | + ], |
| 841 | + }; |
| 842 | + }, |
817 | 843 | }, |
818 | 844 | [AnnotationType.POINT]: { |
819 | 845 | icon: "⚬", |
@@ -858,6 +884,11 @@ export const annotationTypeHandlers: Record< |
858 | 884 | visitGeometry(annotation: Point, callback) { |
859 | 885 | callback(annotation.point, false); |
860 | 886 | }, |
| 887 | + defaultProperties(annotation: Point, scales: vec3) { |
| 888 | + annotation; |
| 889 | + scales; |
| 890 | + return { properties: [], values: [] }; |
| 891 | + }, |
861 | 892 | }, |
862 | 893 | [AnnotationType.AXIS_ALIGNED_BOUNDING_BOX]: { |
863 | 894 | icon: "❑", |
@@ -926,6 +957,11 @@ export const annotationTypeHandlers: Record< |
926 | 957 | callback(annotation.pointA, false); |
927 | 958 | callback(annotation.pointB, false); |
928 | 959 | }, |
| 960 | + defaultProperties(annotation: AxisAlignedBoundingBox, scales: vec3) { |
| 961 | + annotation; |
| 962 | + scales; |
| 963 | + return { properties: [], values: [] }; |
| 964 | + }, |
929 | 965 | }, |
930 | 966 | [AnnotationType.ELLIPSOID]: { |
931 | 967 | icon: "◎", |
@@ -994,6 +1030,11 @@ export const annotationTypeHandlers: Record< |
994 | 1030 | callback(annotation.center, false); |
995 | 1031 | callback(annotation.radii, true); |
996 | 1032 | }, |
| 1033 | + defaultProperties(annotation: Ellipsoid, scales: vec3) { |
| 1034 | + annotation; |
| 1035 | + scales; |
| 1036 | + return { properties: [], values: [] }; |
| 1037 | + }, |
997 | 1038 | }, |
998 | 1039 | }; |
999 | 1040 |
|
|
0 commit comments