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