diff --git a/plugin/omero_iviewer/iviewer_settings.py b/plugin/omero_iviewer/iviewer_settings.py index f3cbf84de..eb004f7de 100644 --- a/plugin/omero_iviewer/iviewer_settings.py +++ b/plugin/omero_iviewer/iviewer_settings.py @@ -40,6 +40,28 @@ 500, int, "Page size for ROI pagination."], + + "omero.web.iviewer.color_palette": + ["COLOR_PALETTE", + "[]", + json.loads, + ("Set of predefined color options for drawing rois" + "Accepts most ways to define a color" + "ex: ['rgb(0,0,0)'],['#000000'],['rgba(0,0,0,0)']...")], + + "omero.web.iviewer.palette_labels": + ["PALETTE_LABELS", + "[]", + json.loads, + ("Text to be displayed below each palette option" + "['Hypercellular'],['Necrotic']...")], + + "omero.web.iviewer.show_palette_only": + ["SHOW_PALETTE_ONLY", + False, + bool, + ("Disables spectrum color picker. Forces users to use preset options" + "Must define a color palette for this setting to work.")], } process_custom_settings(sys.modules[__name__], 'IVIEWER_SETTINGS_MAPPING') diff --git a/plugin/omero_iviewer/views.py b/plugin/omero_iviewer/views.py index cae13f7ed..ddadc432f 100644 --- a/plugin/omero_iviewer/views.py +++ b/plugin/omero_iviewer/views.py @@ -49,6 +49,9 @@ ROI_PAGE_SIZE = getattr(iviewer_settings, 'ROI_PAGE_SIZE') ROI_PAGE_SIZE = min(MAX_LIMIT, ROI_PAGE_SIZE) MAX_PROJECTION_BYTES = getattr(iviewer_settings, 'MAX_PROJECTION_BYTES') +COLOR_PALETTE = getattr(iviewer_settings, 'COLOR_PALETTE') +PALETTE_LABELS = getattr(iviewer_settings, 'PALETTE_LABELS') +SHOW_PALETTE_ONLY = getattr(iviewer_settings, 'SHOW_PALETTE_ONLY') PROJECTIONS = { 'normal': -1, @@ -104,7 +107,11 @@ def index(request, iid=None, conn=None, **kwargs): max_bytes = MAX_PROJECTION_BYTES params['MAX_PROJECTION_BYTES'] = max_bytes - + + params['COLOR_PALETTE'] = COLOR_PALETTE + params['PALETTE_LABELS'] = PALETTE_LABELS + params['SHOW_PALETTE_ONLY'] = SHOW_PALETTE_ONLY + return render( request, 'omero_iviewer/index.html', {'params': params, 'iviewer_url_suffix': u"?_iviewer-%s" % __version__} diff --git a/src/app/context.js b/src/app/context.js index 3679e6c99..6434eb02a 100644 --- a/src/app/context.js +++ b/src/app/context.js @@ -451,8 +451,10 @@ export default class Context { this.interpolate = (interpolate === 'true'); this.version = this.getInitialRequestParam(REQUEST_PARAMS.VERSION); this.roi_page_size = this.initParams[REQUEST_PARAMS.ROI_PAGE_SIZE] || 500; - this.max_projection_bytes = parseInt(this.initParams[REQUEST_PARAMS.MAX_PROJECTION_BYTES], 10) - || (1024 * 1024 * 256); + this.max_projection_bytes = parseInt(this.initParams[REQUEST_PARAMS.MAX_PROJECTION_BYTES], 10) || (1024 * 1024 * 256); + this.color_palette = this.initParams[REQUEST_PARAMS.COLOR_PALETTE] || []; + this.palette_labels = this.initParams[REQUEST_PARAMS.PALETTE_LABELS] || []; + this.show_palette_only = this.initParams[REQUEST_PARAMS.SHOW_PALETTE_ONLY] || false } /** diff --git a/src/regions/regions-edit.js b/src/regions/regions-edit.js index cde8582a0..2a634739f 100644 --- a/src/regions/regions-edit.js +++ b/src/regions/regions-edit.js @@ -889,6 +889,12 @@ export default class RegionsEdit extends EventSubscriber { $(this.element).find('.shape-fill-color') : $(this.element).find('.shape-stroke-color') }; + if (this.context.color_palette != []) { + options.palette = this.context.color_palette; + options.showPaletteOnly = this.context.show_palette_only; + if (this.context.palette_label != []) + options.labels = this.context.palette_labels; + } if (shape) options.change = (color) => this.onColorChange(color.toRgbString(), fill, shape);