Skip to content

Commit 387b490

Browse files
authored
Merge pull request #485 from Tom-TBT/dynamic_lut
Dynamic LUT for iviewer
2 parents 4bf017c + b47822c commit 387b490

File tree

2 files changed

+29
-71
lines changed

2 files changed

+29
-71
lines changed

src/app/context.js

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
REGIONS_STORED_SHAPES
3232
} from '../events/events';
3333
import {
34-
APP_NAME, IMAGE_CONFIG_RELOAD, IVIEWER, INITIAL_TYPES, LUTS_NAMES,
34+
APP_NAME, IMAGE_CONFIG_RELOAD, IVIEWER, INITIAL_TYPES,
3535
LUTS_PNG_URL, PLUGIN_NAME, PLUGIN_PREFIX, REQUEST_PARAMS, SYNC_LOCK,
3636
TABS, URI_PREFIX, WEB_API_BASE, WEBCLIENT, WEBGATEWAY
3737
} from '../utils/constants';
@@ -301,39 +301,43 @@ export default class Context {
301301
* @memberof Context
302302
*/
303303
setUpLuts() {
304-
this.luts_png.url =
305-
this.server + this.getPrefixedURI(WEBGATEWAY, true) + LUTS_PNG_URL;
306-
307-
// determine the luts png height
308-
let lutsPng = new Image();
309-
lutsPng.onload = (e) => {
310-
this.luts_png.height = e.target.naturalHeight;
311-
this.luts_png.image = lutsPng;
312-
for (let [id, conf] of this.image_configs) conf.changed();
313-
}
314-
lutsPng.src = this.luts_png.url;
315-
316-
// now query the luts list
317-
let server = this.server;
318-
let uri_prefix = this.getPrefixedURI(WEBGATEWAY);
319304
$.ajax(
320-
{url : server + uri_prefix + "/luts/",
305+
{url : this.server + this.getPrefixedURI(WEBGATEWAY) + "/luts/",
321306
success : (response) => {
322-
if (typeof response !== 'object' || response === null ||
323-
!Misc.isArray(response.luts)) return;
307+
// Check first whether omero-web can provides LUT dynamically
308+
// and set URL accordingly
309+
let is_dynamic_lut = Boolean(response.png_luts_new);
310+
if (is_dynamic_lut) {
311+
this.luts_png.url =
312+
this.server + this.getPrefixedURI(WEBGATEWAY, false) + "/luts_png/";
313+
} else {
314+
this.luts_png.url =
315+
this.server + this.getPrefixedURI(WEBGATEWAY, true) + LUTS_PNG_URL;
316+
}
317+
318+
// determine the luts png height
319+
let lutsPng = new Image();
320+
lutsPng.onload = (e) => {
321+
this.luts_png.height = e.target.naturalHeight;
322+
this.luts_png.image = lutsPng;
323+
for (let [id, conf] of this.image_configs) conf.changed();
324+
}
325+
lutsPng.src = this.luts_png.url;
326+
327+
if (is_dynamic_lut) {
328+
// If it's dynamic, uses the new list instead
329+
response.png_luts = response.png_luts_new
330+
}
324331

325-
let i=0;
326-
response.luts.map(
332+
response.luts.forEach(
327333
(l) => {
328-
let isInList = LUTS_NAMES.indexOf(l.name) !== -1;
329334
let mapValue =
330335
Object.assign({
331336
nice_name :
332337
l.name.replace(/.lut/g, "").replace(/_/g, " "),
333-
index : isInList ? i : -1
338+
index : is_dynamic_lut ? l.png_index_new : l.png_index
334339
}, l);
335340
this.luts.set(mapValue.name, mapValue);
336-
if (isInList) i++;
337341
});
338342
for (let [id, conf] of this.image_configs) conf.changed();
339343
}
@@ -463,7 +467,7 @@ export default class Context {
463467
}
464468
}
465469
this.show_palette_only = (this.initParams[REQUEST_PARAMS.SHOW_PALETTE_ONLY] != 'False') || false
466-
this.enable_mirror = (this.initParams[REQUEST_PARAMS.ENABLE_MIRROR] != 'False') || false
470+
this.enable_mirror = (this.initParams[REQUEST_PARAMS.ENABLE_MIRROR] != 'False') || false
467471
// nodedescriptors can be empty string or "None" (undefined)
468472
let nds = this.initParams[REQUEST_PARAMS.NODEDESCRIPTORS];
469473
// initially hide left and right panels?

src/utils/constants.js

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -207,52 +207,6 @@ export const PERMISSION_TOOLTIPS = {
207207
*/
208208
export const LUTS_PNG_URL = '/img/luts_10.png';
209209

210-
/**
211-
* luts list for pre-generated png
212-
* @type {Object}
213-
*/
214-
export const LUTS_NAMES = [
215-
'16_colors.lut',
216-
'3-3-2_rgb.lut',
217-
'5_ramps.lut',
218-
'6_shades.lut',
219-
'blue_orange_icb.lut',
220-
'brgbcmyw.lut',
221-
'cool.lut',
222-
'cyan_hot.lut',
223-
'edges.lut',
224-
'fire.lut',
225-
'gem.lut',
226-
'glasbey.lut',
227-
'glasbey_inverted.lut',
228-
'glow.lut',
229-
'grays.lut',
230-
'green_fire_blue.lut',
231-
'hilo.lut',
232-
'ica.lut',
233-
'ica2.lut',
234-
'ica3.lut',
235-
'ice.lut',
236-
'magenta_hot.lut',
237-
'orange_hot.lut',
238-
'phase.lut',
239-
'physics.lut',
240-
'pup_br.lut',
241-
'pup_nr.lut',
242-
'rainbow_rgb.lut',
243-
'red-green.lut',
244-
'red_hot.lut',
245-
'royal.lut',
246-
'sepia.lut',
247-
'smart.lut',
248-
'spectrum.lut',
249-
'thal.lut',
250-
'thallium.lut',
251-
'thermal.lut',
252-
'unionjack.lut',
253-
'yellow_hot.lut'
254-
];
255-
256210
/**
257211
* the right hand panel tab names
258212
* @type {Object}

0 commit comments

Comments
 (0)