Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ the webclient tree:
$ omero config append omero.web.open_with '["omero_figure", "new_figure",
{"supported_objects":["images"], "target": "_blank", "label": "OMERO.figure"}]'


Optional: To change the maximum active channel count from the default of 10:

::

$ omero config set omero.figure.max_active_channels 15


Now restart OMERO.web as normal.


Expand Down
10 changes: 10 additions & 0 deletions omero_figure/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@

warnings.warn("Deprecated. utils.__version__", DeprecationWarning)
OMERO_FIGURE_VERSION = utils.__version__


CUSTOM_SETTINGS_MAPPINGS = {
"omero.figure.max_active_channels": [
"MAX_ACTIVE_CHANNELS",
10,
int,
"Maximum number of active channels allowed in Figure"
],
}
6 changes: 6 additions & 0 deletions omero_figure/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
JsonResponse
from django.views.decorators.http import require_POST
from django.conf import settings
from omero_figure import settings as figure_settings
from django.template import loader
from django.templatetags import static
from datetime import datetime
Expand Down Expand Up @@ -105,6 +106,7 @@ def index(request, file_id=None, conn=None, **kwargs):
length_units = get_length_units()
cfg = conn.getConfigService()
max_bytes = cfg.getConfigValue('omero.pixeldata.max_projection_bytes')
max_active_channels = getattr(figure_settings, 'MAX_ACTIVE_CHANNELS', 10)
is_public_user = "false"
if (hasattr(settings, 'PUBLIC_USER')
and settings.PUBLIC_USER == user.getOmeName()):
Expand All @@ -131,6 +133,10 @@ def index(request, file_id=None, conn=None, **kwargs):
'const MAX_PLANE_SIZE = %s;' % max_plane_size)
html = html.replace('const LENGTH_UNITS = LENGTHUNITS;',
'const LENGTH_UNITS = %s;' % json.dumps(length_units))
html = html.replace('const MAX_ACTIVE_CHANNELS = 10;',
'const MAX_ACTIVE_CHANNELS = %s;'
% max_active_channels)

if max_bytes:
html = html.replace('const MAX_PROJECTION_BYTES = 1024 * 1024 * 256;',
'const MAX_PROJECTION_BYTES = %s;' % max_bytes)
Expand Down
4 changes: 4 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
const MAX_PLANE_SIZE = 10188864;
const MAX_PROJECTION_BYTES = 1024 * 1024 * 256;

// Max active channels for multi-channel images
const MAX_ACTIVE_CHANNELS = 10;
window.MAX_ACTIVE_CHANNELS = MAX_ACTIVE_CHANNELS;

const LOCAL_STORAGE_RECOVERED_FIGURE = "recoveredFigure" + USER_ID;

// Hack! Since the iviewer openwith.js evaluates in global scope and it
Expand Down
27 changes: 26 additions & 1 deletion src/js/models/panel_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Backbone from "backbone";
import _ from "underscore";
import $ from "jquery";
import { rotatePoint } from "../views/util";
import { rotatePoint, figureConfirmDialog } from "../views/util";

// Corresponds to css - allows us to calculate size of labels
var LINE_HEIGHT = 1.43;
Expand Down Expand Up @@ -222,6 +222,18 @@
}
return ch;
});
// Enforce max active channels limit
const maxActive = window.MAX_ACTIVE_CHANNELS || 10;
let activeCount = 0;
data.channels.forEach(ch => {
if (ch.active) {
activeCount += 1;
if (activeCount > maxActive) {
ch.active = false; // disable extra active channels
}
}

});
return data;
},

Expand Down Expand Up @@ -755,6 +767,19 @@
active = !this.get('channels')[cIndex].active;
}

// Enforce max active channels - block if trying to activate beyond limit.
const MAX_ACTIVE_CHANNELS = window.MAX_ACTIVE_CHANNELS || 10;
if (active) {
const channels = this.get('channels') || [];
const activeCount = channels.reduce((acc, ch) => acc + (ch.active ? 1 : 0), 0);
if (!channels[cIndex].active && activeCount >= MAX_ACTIVE_CHANNELS) {
figureConfirmDialog(
"Channels Limit", "Cannot activate the channel. The maximum number of channels is already active.",
["OK"]);
return;
}
}

if (this.get("hilo_enabled") && active) {
let newChs = this.get('channels').map(function(channel, idx) {
return {'active': idx == cIndex};
Expand Down