Skip to content

Commit 3d98353

Browse files
committed
Remove APP_SERVED_BY_OMERO and Luts display logic
1 parent ff86010 commit 3d98353

7 files changed

Lines changed: 13 additions & 53 deletions

File tree

omero_figure/views.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ def index(request, file_id=None, conn=None, **kwargs):
113113
# Load the template html and replace OMEROWEB_INDEX
114114
template = loader.get_template("omero_figure/index.html")
115115
html = template.render({}, request)
116-
html = html.replace('const APP_SERVED_BY_OMERO = false;',
117-
'const APP_SERVED_BY_OMERO = true;')
118116
omeroweb_index = reverse("index")
119117
figure_index = reverse("figure_index")
120118
ping_url = reverse("keepalive_ping")

src/css/figure.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@
10371037
text-align: left;
10381038
}
10391039

1040-
.lutOption span, .lutOption img {
1040+
.lutOption span {
10411041
width: 85px;
10421042
display: inline-block;
10431043
}
@@ -1052,7 +1052,6 @@
10521052
/* NB: when updating png, consider using different name to avoid cache */
10531053
background-size: 100% var(--pngHeight);
10541054
background-image: var(--lutPng);
1055-
background-position: var(--bgPos);
10561055
background-repeat: no-repeat;
10571056
image-rendering: pixelated; /* Universal support since 2021 */
10581057
}

src/index.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// For dev, use this server to load/save figures (needs CORS enabled)
99
const dev_omeroweb_url = "http://localhost:4080/";
1010
// These are updated by views.py when serving this page...
11-
// Flag for knowing if app is served from OMERO (or standalone)
12-
const APP_SERVED_BY_OMERO = false;
1311
const BASE_OMEROWEB_URL = dev_omeroweb_url;
1412
const EXPORT_ENABLED = false;
1513
const SCRIPT_VERSION = "";

src/js/views/channel_slider_view.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -401,17 +401,10 @@ var ChannelSliderView = Backbone.View.extend({
401401
var active = actives.reduce(allEqualFn, actives[0]);
402402
var style = {'background-position': '0 0'}
403403
var lutBgPos = FigureLutPicker.getLutBackgroundPosition(color);
404-
var lutPng = FigureLutPicker.getLutPng(color);
405-
console.log("lutPng", lutPng);
406-
var lutBgCss = '--bgPos: 0 0;';
407-
if (color.endsWith('.lut') && lutPng) {
408-
// lutPng means we have LUT from ome-zarr.js. Apply without offset
409-
lutBgCss = `--bgPos: 0 0; --lutPng: url('${lutPng}'); --pngHeight: 100%;`;
404+
if (color.endsWith('.lut')) {
405+
style['background-position'] = lutBgPos;
410406
color = "ccc";
411-
} else {
412-
lutBgCss = `--bgPos: ${lutBgPos};`
413-
}
414-
if (color.toUpperCase() === "FFFFFF") {
407+
} else if (color.toUpperCase() === "FFFFFF") {
415408
color = "ccc"; // white slider would be invisible
416409
}
417410
if (color == "FFFFFF") color = "ccc"; // white slider would be invisible
@@ -430,7 +423,7 @@ var ChannelSliderView = Backbone.View.extend({
430423
'max': max,
431424
'step': (max - min > SLIDER_INCR_CUTOFF) ? 1 : 0.01,
432425
'active': active,
433-
'lutBgCss': lutBgCss,
426+
'lutBgPos': lutBgPos,
434427
'reverse': reverse,
435428
'color': color,
436429
'isDark': this.isDark(color)

src/js/views/lutpicker.js

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import Backbone from "backbone";
2121
import $ from "jquery";
2222
import _ from 'underscore';
2323
import * as bootstrap from "bootstrap"
24-
import * as omezarr from "ome-zarr.js";
2524

2625
import lut_picker_template from '../../templates/lut_picker.template.html?raw';
2726
import { showModal, getJson } from "./util";
@@ -39,10 +38,6 @@ var LutPickerView = Backbone.View.extend({
3938
initialize:function () {
4039
this.lutModal = new bootstrap.Modal('#lutpickerModal');
4140
this.lut_names = [];
42-
43-
// These will be overwritten with LUTs from OMERO if served by OMERO
44-
this.luts = omezarr.getLuts();
45-
4641
this.loadLuts();
4742
},
4843

@@ -63,24 +58,13 @@ var LutPickerView = Backbone.View.extend({
6358
this.pickedLut = lutName;
6459

6560
// Update preview to show LUT
66-
var lut = this.luts.find(lut => lut.name == lutName);
67-
if (lut.png) {
68-
$(".lutPreview", this.el).css({'background-position': '0 0', 'background-image': "url('" + lut.png + "')", 'background-size': '100% 100%'});
69-
} else {
70-
var bgPos = this.getLutBackgroundPosition(lutName);
71-
$(".lutPreview", this.el).css({'background-position': bgPos, 'background-image': `url(${this.lutsPngUrl})`});
72-
}
61+
var bgPos = this.getLutBackgroundPosition(lutName);
62+
$(".lutPreview", this.el).css({'background-position': bgPos, 'background-image': `url(${this.lutsPngUrl})`});
7363
// Enable OK button
7464
$("button[type='submit']", this.el).removeAttr('disabled');
7565
},
7666

7767
loadLuts: async function(force_reload = false) {
78-
if (!APP_SERVED_BY_OMERO) {
79-
$(":root").css({
80-
"--pngHeight": "100%"
81-
});
82-
return;
83-
}
8468
var url = WEBGATEWAYINDEX + 'luts/';
8569
let cors_headers = { mode: 'cors', credentials: 'include' };
8670
if (force_reload || this.lut_names === undefined || this.lutsPngUrl === undefined || this.luts === undefined) {
@@ -116,14 +100,6 @@ var LutPickerView = Backbone.View.extend({
116100
return this.lutsPngUrl
117101
},
118102

119-
getLutPng(lutName) {
120-
// This will return undefined if the LUTs are loaded from OMERO
121-
var lut = this.luts.find(lut => lut.name == lutName);
122-
if (lut && lut.png) {
123-
return lut.png;
124-
}
125-
},
126-
127103
getLutBackgroundPosition: function(lutName) {
128104
var lutIndex = this.lut_names.indexOf(lutName);
129105
if (lutIndex > -1) {
@@ -149,7 +125,8 @@ var LutPickerView = Backbone.View.extend({
149125
if (options.success) {
150126
this.success = options.success;
151127
}
152-
this.render();
128+
129+
this.loadLuts().then(() => this.render());
153130
},
154131

155132
render:function() {
@@ -163,7 +140,6 @@ var LutPickerView = Backbone.View.extend({
163140
// Add css background-position to each lut to offset luts_10.png
164141
return {'bgPos': this.getLutBackgroundPosition(lut.name),
165142
'name': lut.name,
166-
'png': lut.png, // if LUT is from omezarr.js, we have png in hand
167143
'displayName': this.formatLutName(lut.name)};
168144
}.bind(this));
169145

@@ -175,4 +151,4 @@ var LutPickerView = Backbone.View.extend({
175151

176152
const FigureLutPicker = new LutPickerView();
177153

178-
export default FigureLutPicker;
154+
export default FigureLutPicker

src/templates/channel_slider.template.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
title="<%= _.escape(label) %>"
88
class="btn btn-default channel-btn lutBg <% if (isDark) { print('font-white') } %>"
99
data-index="<%= idx %>"
10-
style="background-color:#<%= color %>; <%= lutBgCss %>">
10+
style="background-color:#<%= color %>; background-position: <%= lutBgPos %>;">
1111

1212
<%= _.escape(label) %>
1313
<div class="<% if(active) { %>ch-btn-down<% } else if (typeof active == 'boolean') { %>ch-btn-up<% } else { %>ch-btn-flat<% }%>">&nbsp</div>
@@ -72,7 +72,7 @@
7272
min="<%= min %>" max="<%= max %>" step="<%= step %>"
7373
type="range" value="<%= startAvg %>"
7474
style="background-color:#<%=color%>;
75-
<%= lutBgCss %>
75+
--bgPos: <%= lutBgPos %>;
7676
--scaleX: <%= reverse ? -1 : 1 %>"/>
7777
<!-- data-slidemin and data-slidemax used to prevent sliding start > end etc -->
7878
<input class="ch_end_slider" data-idx="<%=idx%>" data-slidemin="<%= startAvg %>"

src/templates/lut_picker.template.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
<% _.each(luts, function(lut, i) { %>
66

77
<button type="button" class="btn btn-default lutOption" data-lut="<%= lut.name %>">
8-
<% if (lut.png) { %>
9-
<img height="24px" src="<%= lut.png %>" />
10-
<% } else { %>
11-
<span class="lutBg" style="background-position: <%= lut.bgPos %>;">&nbsp</span>
12-
<% } %>
8+
<span class="lutBg" style="background-position: <%= lut.bgPos %>;">&nbsp</span>
139
<%= lut.displayName %> </button>
1410

1511
<% if (i === parseInt(luts.length/2)) { %>

0 commit comments

Comments
 (0)