Skip to content

Commit

Permalink
quick fix for tags breaking precomputed annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisj committed Oct 3, 2024
1 parent 8b8a9ea commit dc9b080
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/annotation/frontend_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import {
SliceViewChunkSource,
} from "#src/sliceview/frontend.js";
import { StatusMessage } from "#src/status.js";
import type { WatchableValue } from "#src/trackable_value.js";
import { WatchableValue } from "#src/trackable_value.js";
import type { Borrowed, Owned } from "#src/util/disposable.js";
import { ENDIANNESS, Endianness } from "#src/util/endian.js";
import * as matrix from "#src/util/matrix.js";
Expand Down Expand Up @@ -532,7 +532,7 @@ export class MultiscaleAnnotationSource
) {
super();
this.rank = options.rank;
this.properties.value = options.properties;
this.properties = new WatchableValue(options.properties);
this.annotationPropertySerializers = makeAnnotationPropertySerializers(
this.rank,
this.properties.value,
Expand Down
10 changes: 8 additions & 2 deletions src/layer/annotation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import type { SegmentationDisplayState } from "#src/segmentation_display_state/f
import type { TrackableBoolean } from "#src/trackable_boolean.js";
import { TrackableBooleanCheckbox } from "#src/trackable_boolean.js";
import {
ComputedWatchableValue,
makeCachedLazyDerivedWatchableValue,
WatchableValue,
} from "#src/trackable_value.js";
Expand Down Expand Up @@ -705,7 +706,6 @@ export class AnnotationUserLayer extends Base {
this.annotationProjectionRenderScaleTarget.changed.add(
this.specificationChanged.dispatch,
);

this.registerDisposer(
this.localAnnotationProperties.changed.add(() => {
const { localAnnotations } = this;
Expand All @@ -722,12 +722,18 @@ export class AnnotationUserLayer extends Base {
order: -100,
getter: () => new RenderingOptionsTab(this),
});
this.tabs.default = "annotations";
const hideTagsTab = this.registerDisposer(
new ComputedWatchableValue(() => {
return this.localAnnotations === undefined;
}, this.dataSourcesChanged),
);
this.tabs.add("tags", {
label: "Tags",
order: 10,
getter: () => new TagsTab(this),
hidden: hideTagsTab,
});
this.tabs.default = "annotations";
}

syncTagTools = (tagIdentifiers: string[]) => {
Expand Down
20 changes: 19 additions & 1 deletion src/ui/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,23 @@ export class MergedAnnotationStates
}
}

function getAVertexPosition(pos: Float32Array, annotation: Annotation) {
switch (annotation.type) {
case AnnotationType.AXIS_ALIGNED_BOUNDING_BOX:
case AnnotationType.LINE:
pos.set(annotation.pointA);
break;
case AnnotationType.POINT:
pos.set(annotation.point);
break;
case AnnotationType.ELLIPSOID:
pos.set(annotation.center);
break;
}
}

getAVertexPosition;

function getCenterPosition(center: Float32Array, annotation: Annotation) {
switch (annotation.type) {
case AnnotationType.AXIS_ALIGNED_BOUNDING_BOX:
Expand All @@ -187,6 +204,7 @@ function getCenterPosition(center: Float32Array, annotation: Annotation) {
break;
}
}
getCenterPosition;

function setLayerPosition(
layer: UserLayer,
Expand Down Expand Up @@ -240,7 +258,7 @@ const moveToAnnotation = (
const { layerRank } = chunkTransform;
const chunkPosition = new Float32Array(layerRank);
const layerPosition = new Float32Array(layerRank);
getCenterPosition(chunkPosition, annotation);
getAVertexPosition(chunkPosition, annotation);
matrix.transformPoint(
layerPosition,
chunkTransform.chunkToLayerTransform,
Expand Down

0 comments on commit dc9b080

Please sign in to comment.