Here is a mockup for what the viewer and layer api should look like (roughly):
Create a window:
window = gui.newwindow(name, ...other options...)
Note: We should distinguish the concept of 'window' and 'viewer'.
you can have several viewers in a window, organised either as tabs
or side by side, etc... Tabs are probably the best way to do it.
Create or removes a viewer in a window:
viewer = window.addviewer(name=None, ...other options...) %optional name
viewer = window.removeviewer()
Most of the time we just want a viewer straight away:
viewer = gui.newviewer()
This creates the window on the fly...
Even more often, we want an image displayed in a viewer inside of a window, in a one-liner:
viewer = gui.imshow(...list of numpy arrays..., rgb=None)
semi-internal api for adding/removing a layer of a given type:
viewer.addlayer(ImageLayer(... list of numpy arrays ...))
viewer.removelayer(name or index of layer)
convenience api for common layers:
viewer.addimages(... list of numpy arrays ...)
viewer.addpoints(... list of points as nparray ...)
viewer.addlines(... list of lines as nparray ...)
etc...
get a layer from a viewer:
layer = viewer.getlayer(...index or name of layer...)
set the viewer sliders on a given layer:
layer.setposition( tuple of ints )
Note this must be a complete tuple that also includes the displayed dims!
for simplicity we should also have:
layer.setposition(dimindex,position )
Different layers have different available properties, for example:
layer.cmap = ...
layer.opacity = ...
etc...
In the case of image viewers, we have an api for the different layout modes etc...
We can always retrieve the reference to the data that the layer represents:
data = layer.data
for example the numpy array, etc...
And force the layer to refresh itself and reflect any change of the data:
layer.refresh()
Note: we don't have yet a mechanism to know when numpy arrays have changed
their content for example...
Here is a mockup for what the viewer and layer api should look like (roughly):
Create a window:
window = gui.newwindow(name, ...other options...)Note: We should distinguish the concept of 'window' and 'viewer'.
you can have several viewers in a window, organised either as tabs
or side by side, etc... Tabs are probably the best way to do it.
Create or removes a viewer in a window:
viewer = window.addviewer(name=None, ...other options...)%optional nameviewer = window.removeviewer()Most of the time we just want a viewer straight away:
viewer = gui.newviewer()This creates the window on the fly...
Even more often, we want an image displayed in a viewer inside of a window, in a one-liner:
viewer = gui.imshow(...list of numpy arrays..., rgb=None)semi-internal api for adding/removing a layer of a given type:
viewer.addlayer(ImageLayer(... list of numpy arrays ...))viewer.removelayer(name or index of layer)convenience api for common layers:
viewer.addimages(... list of numpy arrays ...)viewer.addpoints(... list of points as nparray ...)viewer.addlines(... list of lines as nparray ...)etc...
get a layer from a viewer:
layer = viewer.getlayer(...index or name of layer...)set the viewer sliders on a given layer:
layer.setposition( tuple of ints )Note this must be a complete tuple that also includes the displayed dims!
for simplicity we should also have:
layer.setposition(dimindex,position )Different layers have different available properties, for example:
layer.cmap = ...layer.opacity = ...etc...
In the case of image viewers, we have an api for the different layout modes etc...
We can always retrieve the reference to the data that the layer represents:
data = layer.datafor example the numpy array, etc...
And force the layer to refresh itself and reflect any change of the data:
layer.refresh()Note: we don't have yet a mechanism to know when numpy arrays have changed
their content for example...