@vitessce/layer-controller 2.0.3-beta.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/deflate-75511377.js +13 -0
  2. package/dist/index-841a1af6.js +148439 -0
  3. package/dist/index.js +9 -3
  4. package/dist/jpeg-6023316d.js +840 -0
  5. package/dist/lerc-82182c45.js +2014 -0
  6. package/dist/lzw-2ab01db2.js +128 -0
  7. package/dist/packbits-2633f360.js +30 -0
  8. package/dist/pako.esm-68f84e2a.js +4022 -0
  9. package/dist/raw-51e455c7.js +12 -0
  10. package/dist/webimage-bbb56d18.js +32 -0
  11. package/dist-tsc/BitmaskChannelController.d.ts +21 -0
  12. package/dist-tsc/BitmaskChannelController.d.ts.map +1 -0
  13. package/{dist → dist-tsc}/BitmaskChannelController.js +3 -4
  14. package/dist-tsc/ChannelOptions.d.ts +13 -0
  15. package/dist-tsc/ChannelOptions.d.ts.map +1 -0
  16. package/{dist → dist-tsc}/ChannelOptions.js +4 -5
  17. package/dist-tsc/ColorPalette.d.ts +5 -0
  18. package/dist-tsc/ColorPalette.d.ts.map +1 -0
  19. package/{dist → dist-tsc}/ColorPalette.js +2 -3
  20. package/dist-tsc/ImageAddButton.d.ts +6 -0
  21. package/dist-tsc/ImageAddButton.d.ts.map +1 -0
  22. package/{dist → dist-tsc}/ImageAddButton.js +2 -3
  23. package/dist-tsc/LayerController.d.ts +10 -0
  24. package/dist-tsc/LayerController.d.ts.map +1 -0
  25. package/{dist → dist-tsc}/LayerController.js +7 -15
  26. package/dist-tsc/LayerControllerSubscriber.d.ts +27 -0
  27. package/dist-tsc/LayerControllerSubscriber.d.ts.map +1 -0
  28. package/{dist → dist-tsc}/LayerControllerSubscriber.js +7 -10
  29. package/dist-tsc/LayerOptions.d.ts +46 -0
  30. package/dist-tsc/LayerOptions.d.ts.map +1 -0
  31. package/{dist → dist-tsc}/LayerOptions.js +4 -8
  32. package/dist-tsc/RasterChannelController.d.ts +35 -0
  33. package/dist-tsc/RasterChannelController.d.ts.map +1 -0
  34. package/{dist → dist-tsc}/RasterChannelController.js +7 -17
  35. package/dist-tsc/RasterChannelController.test.d.ts +2 -0
  36. package/dist-tsc/RasterChannelController.test.d.ts.map +1 -0
  37. package/{dist → dist-tsc}/RasterChannelController.test.js +1 -1
  38. package/dist-tsc/VectorLayerController.d.ts +2 -0
  39. package/dist-tsc/VectorLayerController.d.ts.map +1 -0
  40. package/{dist → dist-tsc}/VectorLayerController.js +2 -6
  41. package/dist-tsc/VolumeOptions.d.ts +16 -0
  42. package/dist-tsc/VolumeOptions.d.ts.map +1 -0
  43. package/{dist → dist-tsc}/VolumeOptions.js +3 -10
  44. package/dist-tsc/constants.d.ts +2 -0
  45. package/dist-tsc/constants.d.ts.map +1 -0
  46. package/dist-tsc/index.d.ts +4 -0
  47. package/dist-tsc/index.d.ts.map +1 -0
  48. package/dist-tsc/index.js +3 -0
  49. package/dist-tsc/shared-channel-controls.d.ts +27 -0
  50. package/dist-tsc/shared-channel-controls.d.ts.map +1 -0
  51. package/{dist → dist-tsc}/shared-channel-controls.js +2 -3
  52. package/dist-tsc/styles.d.ts +76 -0
  53. package/dist-tsc/styles.d.ts.map +1 -0
  54. package/{dist → dist-tsc}/styles.js +1 -6
  55. package/dist-tsc/utils.d.ts +24 -0
  56. package/dist-tsc/utils.d.ts.map +1 -0
  57. package/{dist → dist-tsc}/utils.js +8 -0
  58. package/package.json +20 -11
  59. package/src/BitmaskChannelController.js +62 -0
  60. package/src/ChannelOptions.js +61 -0
  61. package/src/ColorPalette.js +48 -0
  62. package/src/ImageAddButton.js +50 -0
  63. package/src/LayerController.js +596 -0
  64. package/src/LayerControllerSubscriber.js +501 -0
  65. package/src/LayerOptions.js +459 -0
  66. package/src/RasterChannelController.js +245 -0
  67. package/src/RasterChannelController.test.js +23 -0
  68. package/src/VectorLayerController.js +61 -0
  69. package/src/VolumeOptions.js +221 -0
  70. package/src/constants.js +14 -0
  71. package/src/index.js +3 -0
  72. package/src/shared-channel-controls.js +54 -0
  73. package/src/styles.js +116 -0
  74. package/src/utils.js +138 -0
  75. /package/{dist → dist-tsc}/constants.js +0 -0
@@ -0,0 +1,596 @@
1
+ import React, { useState, useRef, useEffect } from 'react';
2
+ import { viv } from '@vitessce/gl';
3
+ import {
4
+ GLOBAL_LABELS, getSourceFromLoader, isRgb,
5
+ } from '@vitessce/spatial-utils';
6
+
7
+ import { Grid, Button, Slider, Tabs, Tab, Accordion } from '@material-ui/core';
8
+ import {
9
+ Add as AddIcon,
10
+ ExpandMore as ExpandMoreIcon,
11
+ Visibility as VisibilityIcon,
12
+ VisibilityOff as VisibilityOffIcon,
13
+ } from '@material-ui/icons';
14
+
15
+
16
+ import { canLoadResolution } from '@vitessce/utils';
17
+ import LayerOptions from './LayerOptions.js';
18
+ import VolumeOptions from './VolumeOptions.js';
19
+ import {
20
+ useControllerSectionStyles,
21
+ StyledAccordionDetails,
22
+ StyledAccordionSummary,
23
+ StyledInputLabel,
24
+ OverflowEllipsisGrid,
25
+ } from './styles.js';
26
+ import { getMultiSelectionStats } from './utils.js';
27
+
28
+ import { DOMAINS } from './constants.js';
29
+
30
+ function TabPanel(props) {
31
+ const {
32
+ children, value, index, ...other
33
+ } = props;
34
+
35
+ return (
36
+ <div
37
+ role="tabpanel"
38
+ hidden={value !== index}
39
+ id={`simple-tabpanel-${index}`}
40
+ aria-labelledby={`simple-tab-${index}`}
41
+ {...other}
42
+ >
43
+ {value === index && children}
44
+ </div>
45
+ );
46
+ }
47
+
48
+ // Set the domain of the sliders based on either a full range or min/max.
49
+ async function getDomainsAndSliders(loader, selections, domainType, use3d) {
50
+ let domains;
51
+ const stats = await getMultiSelectionStats({
52
+ loader: loader.data,
53
+ selections,
54
+ use3d,
55
+ });
56
+ const { sliders } = stats;
57
+ if (domainType === 'Min/Max') {
58
+ // eslint-disable-next-line prefer-destructuring
59
+ domains = stats.domains;
60
+ }
61
+ if (domainType === 'Full') {
62
+ const source = getSourceFromLoader(loader);
63
+ domains = selections.map(() => DOMAINS[source.dtype]);
64
+ }
65
+ return { domains, sliders };
66
+ }
67
+
68
+ const buttonStyles = {
69
+ borderStyle: 'dashed',
70
+ marginTop: '10px',
71
+ fontWeight: 400,
72
+ };
73
+
74
+ /**
75
+ * Controller for the various imaging options (color, opactiy, sliders etc.)
76
+ * @prop {object} imageData Image config object, one of the `images` in the raster schema.
77
+ * @prop {object} layerId Randomly generated id for the image layer that this controller handles.
78
+ * @prop {function} handleLayerRemove Callback for handling the removal of a layer.
79
+ * @prop {object} loader Loader object for the current imaging layer.
80
+ * @prop {function} handleLayerChange Callback for handling the changing of layer properties.
81
+ */
82
+ export default function LayerController(props) {
83
+ const {
84
+ layer,
85
+ name,
86
+ loader,
87
+ theme,
88
+ handleLayerRemove,
89
+ handleLayerChange,
90
+ shouldShowTransparentColor,
91
+ shouldShowDomain,
92
+ shouldShowColormap,
93
+ ChannelController,
94
+ setViewState,
95
+ disable3d,
96
+ setImageLayerCallback,
97
+ setAreLayerChannelsLoading,
98
+ areLayerChannelsLoading,
99
+ disabled,
100
+ spatialHeight,
101
+ spatialWidth,
102
+ disableChannelsIfRgbDetected,
103
+ shouldShowRemoveLayerButton,
104
+ } = props;
105
+
106
+ const {
107
+ colormap,
108
+ opacity,
109
+ channels,
110
+ transparentColor,
111
+ renderingMode,
112
+ xSlice,
113
+ ySlice,
114
+ zSlice,
115
+ resolution,
116
+ use3d,
117
+ modelMatrix,
118
+ } = layer;
119
+ // Channels are used in a lot of callbacks and change handlers
120
+ // so ensuring they have an up to date copy of the data ensures consistency.
121
+ // See: https://github.com/vitessce/vitessce/issues/1036
122
+ const channelRef = useRef(channels);
123
+ useEffect(() => {
124
+ channelRef.current = channels;
125
+ return undefined;
126
+ }, [channels]);
127
+
128
+ const firstSelection = channels[0]?.selection || {};
129
+
130
+ const { data, channels: channelOptions } = loader;
131
+ const [tab, setTab] = useState(0);
132
+
133
+ const handleTabChange = (event, newTab) => {
134
+ setTab(newTab);
135
+ };
136
+ const { labels, shape } = Array.isArray(data) ? data[data.length - 1] : data;
137
+ const [domainType, setDomainType] = useState(layer.domainType);
138
+ const [isExpanded, setIsExpanded] = useState(true);
139
+ const [globalLabelValues, setGlobalLabelValues] = useState(
140
+ GLOBAL_LABELS.filter(
141
+ field => typeof firstSelection[field] === 'number',
142
+ ).reduce((o, key) => ({ ...o, [key]: firstSelection[key] }), {}),
143
+ );
144
+
145
+ function setVisible(v) {
146
+ handleLayerChange({ ...layer, visible: v });
147
+ }
148
+
149
+ function setColormap(v) {
150
+ handleLayerChange({ ...layer, colormap: v });
151
+ }
152
+
153
+ function setOpacity(v) {
154
+ handleLayerChange({ ...layer, opacity: v });
155
+ }
156
+
157
+ function setChannels(v) {
158
+ handleLayerChange({ ...layer, channels: v });
159
+ }
160
+ function setTransparentColor(v) {
161
+ handleLayerChange({ ...layer, transparentColor: v });
162
+ }
163
+ function setRenderingMode(v) {
164
+ handleLayerChange({ ...layer, renderingMode: v });
165
+ }
166
+
167
+ function handleMultiPropertyChange(obj) {
168
+ handleLayerChange({ ...layer, ...obj });
169
+ }
170
+
171
+ function handleSlicerSetting(slice, val) {
172
+ handleLayerChange({ ...layer, [`${slice}Slice`]: val });
173
+ }
174
+
175
+ function setChannelsAndDomainType(newChannels, newDomainType) {
176
+ handleLayerChange({
177
+ ...layer,
178
+ channels: newChannels,
179
+ domainType: newDomainType,
180
+ });
181
+ }
182
+
183
+ function setChannel(v, i) {
184
+ const newChannels = [...channelRef.current];
185
+ newChannels[i] = v;
186
+ handleLayerChange({ ...layer, channels: newChannels });
187
+ }
188
+
189
+ function addChannel(v) {
190
+ const newChannels = [...channelRef.current, v];
191
+ handleLayerChange({ ...layer, channels: newChannels });
192
+ }
193
+
194
+ function removeChannel(i) {
195
+ const newChannels = [...channelRef.current];
196
+ newChannels.splice(i, 1);
197
+ handleLayerChange({ ...layer, channels: newChannels });
198
+ }
199
+
200
+ const setAreAllChannelsLoading = (val) => {
201
+ const newAreLayerChannelsLoading = channelRef.current.map(() => val);
202
+ setAreLayerChannelsLoading(newAreLayerChannelsLoading);
203
+ };
204
+
205
+ // Handles adding a channel, creating a default selection
206
+ // for the current global settings and domain type.
207
+ const handleChannelAdd = async () => {
208
+ const selection = {};
209
+ labels.forEach((label) => {
210
+ // Set new image to default selection for non-global selections (0)
211
+ // and use current global selection otherwise.
212
+ selection[label] = GLOBAL_LABELS.includes(label)
213
+ ? globalLabelValues[label] || 0
214
+ : 0;
215
+ });
216
+ const { domains, sliders } = await getDomainsAndSliders(
217
+ loader,
218
+ [selection],
219
+ domainType,
220
+ use3d,
221
+ );
222
+ const domain = domains[0];
223
+ const slider = domain;
224
+ const color = [255, 255, 255];
225
+ const visible = true;
226
+ const newChannelId = channels.length;
227
+ const newAreLayerChannelsLoading = [...areLayerChannelsLoading];
228
+ newAreLayerChannelsLoading[newChannelId] = true;
229
+ setAreLayerChannelsLoading(newAreLayerChannelsLoading);
230
+ const channel = {
231
+ selection,
232
+ slider,
233
+ visible,
234
+ color,
235
+ };
236
+ setImageLayerCallback(() => {
237
+ setChannel({ ...channel, slider: sliders[0] }, newChannelId);
238
+ const areLayerChannelsLoadingCallback = [...newAreLayerChannelsLoading];
239
+ areLayerChannelsLoadingCallback[newChannelId] = false;
240
+ setAreLayerChannelsLoading(areLayerChannelsLoadingCallback);
241
+ setImageLayerCallback(null);
242
+ });
243
+ addChannel(channel);
244
+ };
245
+
246
+ const handleDomainChange = async (value) => {
247
+ setDomainType(value);
248
+ const selections = channels.map(channel => channel.selection);
249
+ let sliders = channels.map(channel => channel.slider);
250
+ const { domains } = await getDomainsAndSliders(
251
+ loader,
252
+ selections,
253
+ value,
254
+ use3d,
255
+ );
256
+
257
+ // If it's the right-most slider, we take the minimum of that and the new value.
258
+ // Otherwise, we use the maximum of the left-hand side and the new value.
259
+ sliders = sliders.map((slider, i) => {
260
+ const [left, right] = slider;
261
+ return [Math.max(left, domains[i][0]), Math.min(right, domains[i][1])];
262
+ });
263
+
264
+ const newChannels = channels.map((c, i) => ({ ...c, slider: sliders[i] }));
265
+ setChannelsAndDomainType(newChannels, value);
266
+ };
267
+
268
+ // This call updates all channel selections with new global selection from the UI.
269
+ const handleGlobalChannelsSelectionChange = async ({ selection, event }) => {
270
+ const selections = channels.map(channel => ({
271
+ ...channel.selection,
272
+ ...selection,
273
+ }));
274
+ const canUpdateChannels = event.type === 'mouseup' || event.type === 'keydown';
275
+ // Only update domains on a mouseup event for the same reason as above.
276
+ if (canUpdateChannels) {
277
+ setAreAllChannelsLoading(true);
278
+ getDomainsAndSliders(loader, selections, domainType, use3d).then(
279
+ ({ sliders }) => {
280
+ const newChannelsWithSelection = channels.map(c => ({
281
+ ...c,
282
+ selection: { ...c.selection, ...selection },
283
+ }));
284
+ // Set the callback before changing the selection
285
+ // so the callback is used when the layer (re)loads its data.
286
+ setImageLayerCallback(() => {
287
+ setImageLayerCallback(null);
288
+ setAreAllChannelsLoading(false);
289
+ const newChannelsWithSliders = [...newChannelsWithSelection].map(
290
+ (c, i) => ({
291
+ ...c,
292
+ slider: sliders[i],
293
+ }),
294
+ );
295
+ setChannels(newChannelsWithSliders);
296
+ });
297
+ setChannels(newChannelsWithSelection);
298
+ },
299
+ );
300
+ }
301
+ setGlobalLabelValues(prev => ({ ...prev, ...selection }));
302
+ };
303
+
304
+ let channelControllers = [];
305
+ if (labels.length > 0) {
306
+ const channelLabel = labels.find(c => c === 'channel' || c === 'c') || labels[0];
307
+ // Create the channel controllers for each channel.
308
+ channelControllers = channels.map(
309
+ // c is an object like { color, selection, slider, visible }.
310
+ (c, channelId) => {
311
+ // Update the auxiliary store with the current loading state of a channel.
312
+ const setIsLoading = (val) => {
313
+ const newAreLayerChannelsLoading = [...areLayerChannelsLoading];
314
+ newAreLayerChannelsLoading[channelId] = val;
315
+ setAreLayerChannelsLoading(newAreLayerChannelsLoading);
316
+ };
317
+ // Change one property of a channel (for now - soon
318
+ // nested structures allowing for multiple z/t selecitons at once, for example).
319
+ const handleChannelPropertyChange = (property, value) => {
320
+ // property is something like "selection" or "slider."
321
+ // value is the actual change, like { channel: "DAPI" }.
322
+ const update = { [property]: value };
323
+ if (property === 'selection') {
324
+ // Channel is loading until the layer callback is called
325
+ // by the layer, which fetches the raster data.
326
+ setIsLoading(true);
327
+ update.selection = {
328
+ ...globalLabelValues,
329
+ ...update.selection,
330
+ };
331
+ setChannel({ ...c, ...update }, channelId);
332
+ // Call back for raster layer handles update of UI
333
+ // like sliders and the loading state of the channel.
334
+ setImageLayerCallback(async () => {
335
+ const selections = [
336
+ { ...channels[channelId][property], ...value },
337
+ ];
338
+ const { sliders } = await getDomainsAndSliders(
339
+ loader,
340
+ selections,
341
+ domainType,
342
+ use3d,
343
+ );
344
+ [update.slider] = sliders;
345
+ setChannel({ ...c, ...update }, channelId);
346
+ setImageLayerCallback(null);
347
+ setIsLoading(false);
348
+ });
349
+ } else {
350
+ setChannel({ ...c, ...update }, channelId);
351
+ }
352
+ };
353
+ const handleChannelRemove = () => {
354
+ removeChannel(channelId);
355
+ };
356
+ const handleIQRUpdate = async () => {
357
+ const { data: loaderData } = loader;
358
+ const source = Array.isArray(loaderData)
359
+ ? loaderData[loaderData.length - 1]
360
+ : loaderData;
361
+ const raster = await source.getRaster({
362
+ selection: channels[channelId].selection,
363
+ });
364
+ const stats = viv.getChannelStats(raster.data);
365
+ const { q1, q3 } = stats;
366
+ setChannel({ ...c, slider: [q1, q3] }, channelId);
367
+ };
368
+ return (
369
+ <ChannelController
370
+ // eslint-disable-next-line react/no-array-index-key
371
+ key={`channel-controller-${channelId}`}
372
+ dimName={channelLabel}
373
+ visibility={c.visible}
374
+ selectionIndex={c.selection[channelLabel]}
375
+ slider={c.slider}
376
+ color={c.color}
377
+ channels={channels}
378
+ channelId={channelId}
379
+ domainType={domainType}
380
+ loader={loader}
381
+ globalLabelValues={globalLabelValues}
382
+ theme={theme}
383
+ channelOptions={channelOptions}
384
+ colormapOn={Boolean(colormap)}
385
+ handlePropertyChange={handleChannelPropertyChange}
386
+ handleChannelRemove={handleChannelRemove}
387
+ handleIQRUpdate={handleIQRUpdate}
388
+ setRasterLayerCallback={setImageLayerCallback}
389
+ isLoading={areLayerChannelsLoading[channelId]}
390
+ use3d={use3d}
391
+ />
392
+ );
393
+ },
394
+ );
395
+ }
396
+
397
+ const controllerSectionClasses = useControllerSectionStyles();
398
+
399
+ const { visible } = layer;
400
+ const visibleSetting = typeof visible === 'boolean' ? visible : true;
401
+ const Visibility = visibleSetting ? VisibilityIcon : VisibilityOffIcon;
402
+ // Only show Volume tabs if 3D is available.
403
+ const hasViewableResolutions = Boolean(
404
+ Array.from({
405
+ length: loader.data.length,
406
+ }).filter((_, res) => canLoadResolution(loader.data, res)).length,
407
+ );
408
+ const useVolumeTabs = !disable3d && shape[labels.indexOf('z')] > 1 && hasViewableResolutions;
409
+ const FullController = (
410
+ <>
411
+ <LayerOptions
412
+ channels={channels}
413
+ opacity={opacity}
414
+ colormap={colormap}
415
+ transparentColor={transparentColor}
416
+ domainType={domainType}
417
+ // Only allow for global dimension controllers that
418
+ // exist in the `dimensions` part of the loader.
419
+ globalControlLabels={labels.filter(label => GLOBAL_LABELS.includes(label))}
420
+ globalLabelValues={globalLabelValues}
421
+ handleOpacityChange={setOpacity}
422
+ handleColormapChange={setColormap}
423
+ handleGlobalChannelsSelectionChange={
424
+ handleGlobalChannelsSelectionChange
425
+ }
426
+ handleTransparentColorChange={setTransparentColor}
427
+ disableChannelsIfRgbDetected={
428
+ isRgb(loader, channels) && disableChannelsIfRgbDetected
429
+ }
430
+ handleDomainChange={handleDomainChange}
431
+ shouldShowTransparentColor={shouldShowTransparentColor}
432
+ shouldShowDomain={shouldShowDomain}
433
+ shouldShowColormap={shouldShowColormap}
434
+ use3d={use3d}
435
+ loader={loader}
436
+ handleMultiPropertyChange={handleMultiPropertyChange}
437
+ resolution={resolution}
438
+ disable3d={disable3d}
439
+ setRasterLayerCallback={setImageLayerCallback}
440
+ setAreAllChannelsLoading={setAreAllChannelsLoading}
441
+ setViewState={setViewState}
442
+ spatialHeight={spatialHeight}
443
+ spatialWidth={spatialWidth}
444
+ modelMatrix={modelMatrix}
445
+ />
446
+ {isRgb(loader, channels) && disableChannelsIfRgbDetected
447
+ ? null
448
+ : channelControllers}
449
+ {isRgb(loader, channels) && disableChannelsIfRgbDetected ? null : (
450
+ <Button
451
+ disabled={channels.length === viv.MAX_CHANNELS}
452
+ onClick={handleChannelAdd}
453
+ fullWidth
454
+ variant="outlined"
455
+ style={buttonStyles}
456
+ startIcon={<AddIcon />}
457
+ size="small"
458
+ >
459
+ Add Channel
460
+ </Button>
461
+ )}
462
+ </>
463
+ );
464
+ return (
465
+ <Accordion
466
+ className={controllerSectionClasses.root}
467
+ onChange={(e, expanded) => !disabled
468
+ && setIsExpanded(
469
+ expanded && e?.target?.attributes?.role?.value === 'presentation',
470
+ )
471
+ }
472
+ TransitionProps={{ enter: false }}
473
+ expanded={!disabled && isExpanded}
474
+ >
475
+ <StyledAccordionSummary
476
+ expandIcon={<ExpandMoreIcon role="presentation" />}
477
+ aria-controls={`layer-${name}-controls`}
478
+ >
479
+ <Grid container direction="column" m={1} justifyContent="center">
480
+ <OverflowEllipsisGrid item>
481
+ <Button
482
+ onClick={(e) => {
483
+ if (!disabled) {
484
+ // Needed to prevent affecting the expansion panel from changing
485
+ e.stopPropagation();
486
+ const nextVisible = typeof visible === 'boolean' ? !visible : false;
487
+ setVisible(nextVisible);
488
+ }
489
+ }}
490
+ style={{
491
+ marginRight: 8,
492
+ marginBottom: 2,
493
+ padding: 0,
494
+ minWidth: 0,
495
+ }}
496
+ >
497
+ <Visibility />
498
+ </Button>
499
+ {name}
500
+ </OverflowEllipsisGrid>
501
+ {!disabled && !isExpanded && !use3d && (
502
+ <Grid
503
+ container
504
+ direction="row"
505
+ alignItems="center"
506
+ justifyContent="center"
507
+ >
508
+ <Grid item xs={6}>
509
+ <StyledInputLabel htmlFor={`layer-${name}-opacity-closed`}>
510
+ Opacity:
511
+ </StyledInputLabel>
512
+ </Grid>
513
+ <Grid item xs={6}>
514
+ <Slider
515
+ id={`layer-${name}-opacity-closed`}
516
+ value={opacity}
517
+ onChange={(e, v) => setOpacity(v)}
518
+ valueLabelDisplay="auto"
519
+ getAriaLabel={() => 'opacity slider'}
520
+ min={0}
521
+ max={1}
522
+ step={0.01}
523
+ orientation="horizontal"
524
+ />
525
+ </Grid>
526
+ </Grid>
527
+ )}
528
+ </Grid>
529
+ </StyledAccordionSummary>
530
+ <StyledAccordionDetails>
531
+ {useVolumeTabs ? (
532
+ <>
533
+ <Tabs
534
+ value={tab}
535
+ onChange={handleTabChange}
536
+ aria-label="simple tabs example"
537
+ style={{ height: '24px', minHeight: '24px' }}
538
+ >
539
+ <Tab
540
+ label="Channels"
541
+ style={{
542
+ fontSize: '.75rem',
543
+ bottom: 12,
544
+ width: '50%',
545
+ minWidth: '50%',
546
+ }}
547
+ disableRipple
548
+ />
549
+ <Tab
550
+ label="Volume"
551
+ style={{
552
+ fontSize: '.75rem',
553
+ bottom: 12,
554
+ width: '50%',
555
+ minWidth: '50%',
556
+ }}
557
+ />
558
+ </Tabs>
559
+ <TabPanel value={tab} index={0}>
560
+ {FullController}
561
+ </TabPanel>
562
+ <TabPanel value={tab} index={1} style={{ marginTop: 4 }}>
563
+ <VolumeOptions
564
+ loader={loader}
565
+ handleSlicerSetting={handleSlicerSetting}
566
+ handleRenderingModeChange={setRenderingMode}
567
+ renderingMode={renderingMode}
568
+ xSlice={xSlice}
569
+ ySlice={ySlice}
570
+ zSlice={zSlice}
571
+ use3d={use3d}
572
+ setViewState={setViewState}
573
+ spatialHeight={spatialHeight}
574
+ spatialWidth={spatialWidth}
575
+ modelMatrix={modelMatrix}
576
+ />
577
+ </TabPanel>
578
+ </>
579
+ ) : (
580
+ FullController
581
+ )}
582
+ {shouldShowRemoveLayerButton ? (
583
+ <Button
584
+ onClick={handleLayerRemove}
585
+ fullWidth
586
+ variant="outlined"
587
+ style={buttonStyles}
588
+ size="small"
589
+ >
590
+ Remove Image Layer
591
+ </Button>
592
+ ) : null}
593
+ </StyledAccordionDetails>
594
+ </Accordion>
595
+ );
596
+ }