Skip to content

Commit

Permalink
feat: initial ViewerEvent SetImageEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Mar 17, 2024
1 parent 25689cd commit 1e085f5
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 0 deletions.
64 changes: 64 additions & 0 deletions model/itk-viewer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ description: >-
license: https://creativecommons.org/publicdomain/zero/1.0/
prefixes:
itk: https://w3id.org/itk/
wasm: https://w3id.org/itk/wasm
viewer: https://w3id.org/itk/viewer
linkml: https://w3id.org/linkml/
imports:
Expand Down Expand Up @@ -61,6 +62,11 @@ classes:
required: true
ifabsent: int(480)

Image:
description: >-
An itk-wasm Image to be displayed in the viewer.
class_uri: wasm:Image

MultiscaleImage:
abstract: true
is_a: Actor
Expand All @@ -69,6 +75,15 @@ classes:
that supports efficient rendering at multiple resolutions.
class_uri: viewer:MultiscaleImage

DataManager:
abstract: true
is_a: Actor
description: >-
A data manager is an actor that manages the loading and caching of data for rendering.
class_uri: viewer:DataManager
slots:
- images

Renderer:
abstract: true
is_a: Actor
Expand Down Expand Up @@ -106,6 +121,29 @@ classes:
range: EventType
required: true

ViewerEvent:
abstract: true
is_a: Event
description: >-
A ViewerEvent is an Event that can be sent to a Viewer.
class_uri: viewer:ViewerEvent
slot_usage:
type:
range: ViewerEventType

SetImageEvent:
is_a: ViewerEvent
description: >-
A SetImageEvent is an Event that sets an image to be displayed in a viewer.
class_uri: viewer:SetImageEvent
slots:
- image
attributes:
name:
description: >-
The name of the image to be displayed in the viewer.
range: string

RendererEvent:
abstract: true
is_a: Event
Expand All @@ -129,12 +167,28 @@ slots:
domain: Renderer
range: Viewport
required: true

unknown_event_action:
description: >-
The action to take when an unknown event is received.
domain: Actor
range: UnknownEventAction

image:
description: >-
The image to be displayed in the viewer.
domain: SetImageEvent
range: Image
required: true

images:
description: >-
The images to be displayed in the viewer.
domain: DataManager
range: Image
multivalued: true
required: true

enums:
EventType:
description: >-
Expand All @@ -156,6 +210,16 @@ enums:
description: >-
Throw an error.
ViewerEventType:
description: >-
The types of events that can be sent to viewers.
enum_uri: viewer:ViewerEventType
inherits: EventType
permissible_values:
SetImage:
description: >-
Set an image to be displayed in the viewer.
RendererEventType:
description: >-
The types of render events that can be sent to renderers.
Expand Down
48 changes: 48 additions & 0 deletions packages/viewer/python/itkviewer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ class UnknownEventAction(str, Enum):



class ViewerEventType(str, Enum):
"""
The types of events that can be sent to viewers.
"""
# Set an image to be displayed in the viewer.
SetImage = "SetImage"



class RendererEventType(str, Enum):
"""
The types of render events that can be sent to renderers.
Expand Down Expand Up @@ -90,6 +99,14 @@ class Viewport(Actor):



class Image(ConfiguredBaseModel):
"""
An itk-wasm Image to be displayed in the viewer.
"""
None



class MultiscaleImage(Actor):
"""
A multiscale image is a multi-dimensional image, based on the OME-Zarr data model, often preprocessed, that supports efficient rendering at multiple resolutions.
Expand All @@ -98,6 +115,15 @@ class MultiscaleImage(Actor):



class DataManager(Actor):
"""
A data manager is an actor that manages the loading and caching of data for rendering.
"""
images: List[Image] = Field(default_factory=list, description="""The images to be displayed in the viewer.""")
unknown_event_action: Optional[UnknownEventAction] = Field(None, description="""The action to take when an unknown event is received.""")



class Renderer(Actor):
"""
A renderer is an actor that renders a scene to an in-memory RGB image for display in a viewport.
Expand All @@ -117,6 +143,24 @@ class Event(ConfiguredBaseModel):



class ViewerEvent(Event):
"""
A ViewerEvent is an Event that can be sent to a Viewer.
"""
type: ViewerEventType = Field(..., description="""The type of the event.""")



class SetImageEvent(ViewerEvent):
"""
A SetImageEvent is an Event that sets an image to be displayed in a viewer.
"""
image: Image = Field(..., description="""The image to be displayed in the viewer.""")
name: Optional[str] = Field(None, description="""The name of the image to be displayed in the viewer.""")
type: ViewerEventType = Field(..., description="""The type of the event.""")



class RendererEvent(Event):
"""
A RendererEvent is an Event supported by a Renderer.
Expand All @@ -139,9 +183,13 @@ class RenderEvent(RendererEvent):
Actor.update_forward_refs()
Viewer.update_forward_refs()
Viewport.update_forward_refs()
Image.update_forward_refs()
MultiscaleImage.update_forward_refs()
DataManager.update_forward_refs()
Renderer.update_forward_refs()
Event.update_forward_refs()
ViewerEvent.update_forward_refs()
SetImageEvent.update_forward_refs()
RendererEvent.update_forward_refs()
RenderEvent.update_forward_refs()

0 comments on commit 1e085f5

Please sign in to comment.