Skip to content

Commit

Permalink
Fix non 3d annotations appearing in 3D viewport (#9)
Browse files Browse the repository at this point in the history
* Fix non 3d annotations appearing in 3D viewport

* Add toolContext in annotation metadata

* Refactor code
  • Loading branch information
rodrigobasilio2022 authored Dec 21, 2023
1 parent c1dfbe4 commit 925e880
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/tools/src/types/AnnotationTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ type Annotation = {
* VolumeId of the volume that the tool was configured to work on.
*/
volumeId?: string;
/**
* The context of the annotation: 2D or 3D. If empty it will be considered as 2d context
*/
toolContext?: string;
};
/**
* Data for annotation, Derivatives need to define their own data types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export default function filterAnnotationsForDisplay(
spacingInNormalDirection
);
} else if (viewport instanceof VolumeViewport3D) {
return annotations;
return annotations.filter((annotation) => {
return annotation.metadata?.toolContext?.toUpperCase() === '3D';
});
} else {
throw new Error(`Viewport Type ${viewport.type} not supported`);
}
Expand Down

0 comments on commit 925e880

Please sign in to comment.