@@ -14,9 +14,9 @@ class DashVolumeSlicer:
14
14
app (dash.Dash): the Dash application instance.
15
15
volume (ndarray): the 3D numpy array to slice through.
16
16
axis (int): the dimension to slice in. Default 0.
17
- volume_id (str): the id to use for the volume. By default this is a
18
- hash of ``id(volume)``. Slicers that have the same volume -id show
19
- each-other's positions with line indicators .
17
+ scene_id (str): the scene that this slicer is part of. Slicers
18
+ that have the same scene -id show each-other's positions with
19
+ line indicators. By default this is a hash of ``id(volume)`` .
20
20
21
21
This is a placeholder object, not a Dash component. The components
22
22
that make up the slicer can be accessed as attributes:
@@ -29,16 +29,16 @@ class DashVolumeSlicer:
29
29
Each component is given a dict-id with the following keys:
30
30
31
31
* "context": a unique string id for this slicer instance.
32
- * "volume ": the volume_id .
32
+ * "scene ": the scene_id .
33
33
* "axis": the int axis.
34
- * "name": the name of the component.
34
+ * "name": the name of the (sub) component.
35
35
36
36
TODO: iron out these details, list the stores that are public
37
37
"""
38
38
39
39
_global_slicer_counter = 0
40
40
41
- def __init__ (self , app , volume , axis = 0 , volume_id = None ):
41
+ def __init__ (self , app , volume , axis = 0 , scene_id = None ):
42
42
if not isinstance (app , Dash ):
43
43
raise TypeError ("Expect first arg to be a Dash app." )
44
44
self ._app = app
@@ -51,14 +51,14 @@ def __init__(self, app, volume, axis=0, volume_id=None):
51
51
raise ValueError ("The given axis must be 0, 1, or 2." )
52
52
self ._axis = int (axis )
53
53
# Check and store id
54
- if volume_id is None :
55
- volume_id = hex (id (volume ))
56
- elif not isinstance (volume_id , str ):
57
- raise TypeError ("volume_id must be a string" )
58
- self .volume_id = volume_id
54
+ if scene_id is None :
55
+ scene_id = "volume_" + hex (id (volume ))[ 2 :]
56
+ elif not isinstance (scene_id , str ):
57
+ raise TypeError ("scene_id must be a string" )
58
+ self .scene_id = scene_id
59
59
# Get unique id scoped to this slicer object
60
60
DashVolumeSlicer ._global_slicer_counter += 1
61
- self .context_id = "slicer " + str (DashVolumeSlicer ._global_slicer_counter )
61
+ self .context_id = "slicer_ " + str (DashVolumeSlicer ._global_slicer_counter )
62
62
63
63
# Get the slice size (width, height), and max index
64
64
arr_shape = list (volume .shape )
@@ -136,7 +136,7 @@ def _subid(self, name):
136
136
# todo: is there a penalty for using a dict-id vs a string-id?
137
137
return {
138
138
"context" : self .context_id ,
139
- "volume-id " : self .volume_id ,
139
+ "scene " : self .scene_id ,
140
140
"axis" : self ._axis ,
141
141
"name" : name ,
142
142
}
@@ -216,7 +216,6 @@ def _create_client_callbacks(self):
216
216
let x0 = 0, y0 = 0, dx = 1, dy = 1;
217
217
//slice_cache[new_index] = undefined; // todo: disabled cache for now!
218
218
// Maybe we do not need an update
219
- console.log(slice_size)
220
219
if (!data) {
221
220
data = lowres[index];
222
221
// Scale the image to take the exact same space as the full-res
@@ -287,14 +286,14 @@ def _create_client_callbacks(self):
287
286
y: y,
288
287
hoverinfo: 'skip',
289
288
version: version
290
- }
289
+ };
291
290
}
292
291
""" ,
293
292
Output (self ._subid ("_indicators" ), "data" ),
294
293
[
295
294
Input (
296
295
{
297
- "volume-id " : self .volume_id ,
296
+ "scene " : self .scene_id ,
298
297
"context" : ALL ,
299
298
"name" : "index" ,
300
299
"axis" : axis ,
0 commit comments