Skip to content

Commit

Permalink
Merge pull request ome#1 from barrettMCW/colorPalette
Browse files Browse the repository at this point in the history
WIP: should show preset and have all configs
  • Loading branch information
barrettMCW authored May 28, 2022
2 parents f98323a + 0fdd4ab commit 0206e5d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
22 changes: 22 additions & 0 deletions plugin/omero_iviewer/iviewer_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
9 changes: 8 additions & 1 deletion plugin/omero_iviewer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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__}
Expand Down
6 changes: 4 additions & 2 deletions src/app/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/regions/regions-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0206e5d

Please sign in to comment.