-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: Annotation data model (annotations pt. 1) #499
base: main
Are you sure you want to change the base?
Conversation
|
Coverage Report
File Coverage
|
* Wrapper around the SharedWorkerPool method `getMotionDeltas`. Returns a | ||
* debounced motion delta array for the given dataset and vector field | ||
* configuration. | ||
* @param dataset The dataset to calculate motion deltas for. | ||
* @param workerPool The worker pool to use for asynchronous calculations. | ||
* @param config The vector field configuration to use. | ||
* @param debounceMs The debounce time in milliseconds. Defaults to 100ms. | ||
* @returns The motion delta array or `null` if the dataset is invalid. Data will be | ||
* asynchronously updated as calculations complete. | ||
* @returns The motion delta array or `null` if the dataset is invalid. Data | ||
* will be asynchronously updated as calculations complete. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tidied this comment slightly
fix: Linting refactor: Cleanup comments in AnnotationData
refactor: Removed unused method from AnnotationData
fix: Linting refactor: Renamed methods for consistency doc: Updated comment refactor: Code cleanup
6ed64e3
to
4fc258f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
} ; | ||
|
||
export const useAnnotations = (): AnnotationState => { | ||
const annotationData = useConstructor(() => new AnnotationData()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't remember if I looked at this before but it's a nifty util
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Liking this overall! Approving preemptively since I left it hanging over the break and because all my comments are optional/matters of opinion, and you're the expert on where this code goes from here and what it needs. A couple of those optional comments are relatively substantial though.
import Dataset from "../Dataset"; | ||
import SharedWorkerPool from "../workers/SharedWorkerPool"; | ||
|
||
// TODO: Move this to a folder outside of `colorizer`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to this - still like the idea of keeping colorizer
independent of React
getLabels(): LabelData[] { | ||
return [...this.labelData]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Why does this copy, rather than just returning
this.labelData
? - Is it a problem that this shallow-copies? Modifying a member of the returned array will (if I'm not mistaken) modify the same
LabelData
object stored inthis.labelData
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I wanted to protect the label data and make it readonly, but you're 100% right that you can still mutate the underlying objects. At the very least this prevents changing of the label ordering which would mess up the UI rendering.
Co-authored-by: Cameron Fraser <[email protected]>
Problem
Part 1 of 5ish for #484, annotation prototyping!
This PR implements the data model used for annotations. It syncs a pure TS class with React state using a hook to encapsulate all changes. This isn't wired up to anything yet in this PR, but will be used extensively in the next couple PRs for this feature.
Note that this change is missing track information, which means the API will change slightly in the near future.
Estimated review size: medium, 30 minutes (line count is higher due to unit testing)
(Also, you can see the end result of all 5 of the annotation prototype PRs here: https://allen-cell-animated.github.io/timelapse-colorizer/pr-preview-internal/pr-498/)
Solution
AnnotationData
class, which stores the current annotation state in the app.useAnnotations
hook inreact_utils.ts
.AnnotationData
.AnnotationData
so state is updated accordingly.Type of change