DataModel
Observable collection of datasets with unique names.
Extends
Methods
| Method | Description |
|---|---|
| loadFile() | Loads a dataset with the given path from the wasm filesystem. |
| size() | The number of datasets in the model. |
| data() | Returns all datasets as a HandleArray. |
| get() | Returns the dataset at the given index or null if the index is out of bounds. |
| includes() | Returns true if the given dataset is in the data model. |
| find() | Returns the dataset with the given name, or null if not found. |
| getImage() | Returns the first SharedImageSet matching the given kind and modality. |
| getImages() | Returns all SharedImageSets matching the given kind and modality. |
| add() | Adds a dataset to the data model. |
| remove() | Removes the given dataset from the DataModel. |
| clear() | Removes all datasets from the DataModel. |
| onDataAdded() | Fires when a dataset is added. |
| onDataAboutToBeRemoved() | Fires directly before a dataset is removed. |
Inherited from ClassHandle
| Method | Description |
|---|---|
| isAliasOf() | Returns true if this handle and other alias the same underlying C++ object. |
| delete() | Releases this JavaScript handle. |
| deleteLater() | Schedules this handle for deferred deletion and returns this handle. |
| isDeleted() | Returns true if this handle has already been deleted. |
| [dispose]() | Releases this handle when the enclosing scope exits, so a handle can be declared with using instead of calling delete() later manually. |
| clone() | Returns a new JavaScript handle aliasing the same underlying C++ object. |
loadFile()
loadFile(path: EmbindString, format?: FileFormat): HandleArray<Data>;Loads a dataset with the given path from the wasm filesystem.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | EmbindString | Path to file. |
format? | FileFormat | The file format. If omitted, tries to automatically detect it from the filename extension, then file content if no known extension is present. |
Returns
List of loaded datasets.
size()
size(): number;The number of datasets in the model.
Returns
number
data()
data(): HandleArray<Data>;Returns all datasets as a HandleArray.
Returns
get()
get(index: number): Data | null;Returns the dataset at the given index or null if the index is out of bounds.
Parameters
| Parameter | Type |
|---|---|
index | number |
Returns
Data | null
includes()
includes(data: Data | null): boolean;Returns true if the given dataset is in the data model.
Parameters
| Parameter | Type |
|---|---|
data | Data | null |
Returns
boolean
find()
find(name: EmbindString): Data | null;Returns the dataset with the given name, or null if not found.
Parameters
| Parameter | Type |
|---|---|
name | EmbindString |
Returns
Data | null
getImage()
getImage(kind?: DataKind, modality?: DataModality): SharedImageSet | null;Returns the first SharedImageSet matching the given kind and modality.
DataKind "UNKNOWN" matches all kinds and DataModality "NA" matches all modalities.
Parameters
| Parameter | Type |
|---|---|
kind? | DataKind |
modality? | DataModality |
Returns
SharedImageSet | null
getImages()
getImages(kind?: DataKind, modality?: DataModality): HandleArray<SharedImageSet>;Returns all SharedImageSets matching the given kind and modality.
DataKind "UNKNOWN" matches all kinds and DataModality "NA" matches all modalities.
Parameters
| Parameter | Type |
|---|---|
kind? | DataKind |
modality? | DataModality |
Returns
add()
add(data: Data | null): boolean;Adds a dataset to the data model.
The model takes shared ownership of the dataset until it is removed via remove() or clear().
Parameters
| Parameter | Type |
|---|---|
data | Data | null |
Returns
boolean
True if the dataset was added successfully.
remove()
remove(data: Data | null): boolean;Removes the given dataset from the DataModel.
Parameters
| Parameter | Type |
|---|---|
data | Data | null |
Returns
boolean
True if the dataset was removed successfully.
clear()
clear(): void;Removes all datasets from the DataModel.
Returns
void
onDataAdded()
onDataAdded(callback: (data: Data) => void): () => void;Fires when a dataset is added.
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | (data: Data) => void | Called with the added data. |
Returns
Unsubscribe function.
() => void
onDataAboutToBeRemoved()
onDataAboutToBeRemoved(callback: (data: Data) => void): () => void;Fires directly before a dataset is removed.
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | (data: Data) => void | Called with the data about to be removed. |
Returns
Unsubscribe function.
() => void