mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2025-12-12 07:40:26 -08:00
fix issue #234
This commit is contained in:
committed by
Matthieu Baumann
parent
35f6037f7f
commit
c2dd66c5b3
@@ -36,7 +36,7 @@
|
||||
|
||||
// Colormap config options
|
||||
this.colormap = (options && options.colormap) || "native";
|
||||
this.colormap = formatColormap(this.colormap);
|
||||
this.colormap = this.colormap.toLowerCase();
|
||||
|
||||
this.stretch = (options && options.stretch) || "linear";
|
||||
this.stretch = this.stretch.toLowerCase();
|
||||
@@ -102,7 +102,6 @@
|
||||
}
|
||||
|
||||
ColorCfg.prototype.setOptions = function(options) {
|
||||
if (options.colormap)
|
||||
this.setColormap(options.colormap, options)
|
||||
|
||||
this.setCuts(options.minCut, options.maxCut)
|
||||
@@ -207,43 +206,20 @@
|
||||
return this.additiveBlending;
|
||||
};
|
||||
|
||||
var formatColormap = function(colormap) {
|
||||
/// colormap
|
||||
// Make it case insensitive
|
||||
colormap = colormap.toLowerCase();
|
||||
/*if (!ColorCfg.COLORMAPS.includes(colormap)) {
|
||||
console.warn("The colormap \'" + colormap + "\' is not supported. You should use one of the following: " + ColorCfg.COLORMAPS + "\n\'grayscale\' has been chosen by default.")
|
||||
// If the user specify a colormap that is not supported,
|
||||
// then set it to grayscale
|
||||
colormap = "grayscale";
|
||||
}*/
|
||||
|
||||
return colormap;
|
||||
}
|
||||
|
||||
// @api
|
||||
// Optional arguments,
|
||||
ColorCfg.prototype.setColormap = function(colormap = "native", options) {
|
||||
if (colormap == null || colormap == undefined)
|
||||
return;
|
||||
|
||||
ColorCfg.prototype.setColormap = function(colormap, options) {
|
||||
/// colormap
|
||||
// Make it case insensitive
|
||||
let cmap = formatColormap(colormap);
|
||||
this.colormap = (colormap && colormap.toLowerCase()) || this.colormap;
|
||||
|
||||
/// stretch
|
||||
let stretch = (options && options.stretch) || this.stretch || "linear";
|
||||
stretch = stretch.toLowerCase();
|
||||
this.stretch = stretch.toLowerCase()
|
||||
|
||||
/// reversed
|
||||
let reversed = false;
|
||||
if (options && options.reversed === true) {
|
||||
reversed = true;
|
||||
if (options && options.reversed !== undefined) {
|
||||
this.reversed = options.reversed;
|
||||
}
|
||||
|
||||
this.colormap = cmap;
|
||||
this.stretch = stretch;
|
||||
this.reversed = reversed;
|
||||
}
|
||||
|
||||
// @api
|
||||
|
||||
@@ -604,7 +604,8 @@ export let HiPS = (function () {
|
||||
*
|
||||
* @memberof HiPS
|
||||
*
|
||||
* @param {string} [colormap="grayscale"] - The colormap label to use. See {@link https://matplotlib.org/stable/users/explain/colors/colormaps.html|here} for more info about colormaps.
|
||||
* @param {string} [colormap] - The colormap label to use. See {@link https://matplotlib.org/stable/users/explain/colors/colormaps.html|here} for more info about colormaps.
|
||||
* If null or undefined, the colormap type is not changed.
|
||||
* Possible values are:
|
||||
* <br>"blues"
|
||||
* <br>"cividis"
|
||||
@@ -765,6 +766,12 @@ export let HiPS = (function () {
|
||||
*/
|
||||
HiPS.prototype.setOptions = function(options) {
|
||||
this.colorCfg.setOptions(options);
|
||||
|
||||
// FIXME, change api of setColormap to take an option object having a name field
|
||||
if (options.colormap == null || options.colormap == undefined) {
|
||||
delete options.colormap;
|
||||
}
|
||||
|
||||
this.options = {...this.options, ...options};
|
||||
|
||||
this._updateMetadata();
|
||||
|
||||
@@ -49,7 +49,7 @@ import { Form } from "../Widgets/Form.js";
|
||||
monochrome: true,
|
||||
url: luminosityIconUrl
|
||||
},
|
||||
tooltip: {content: 'Luminosity sliders', position: {direction: 'bottom'}},
|
||||
tooltip: {content: 'Contrast', position: {direction: 'bottom'}},
|
||||
action: (e) => {
|
||||
const content = Layout.vertical({
|
||||
layout: [self.selector, self.luminositySettingsContent]
|
||||
@@ -63,7 +63,7 @@ import { Form } from "../Widgets/Form.js";
|
||||
monochrome: true,
|
||||
url: opacityIconUrl
|
||||
},
|
||||
tooltip: {content: 'Opacity slider', position: {direction: 'bottom'}},
|
||||
tooltip: {content: 'Opacity', position: {direction: 'bottom'}},
|
||||
action: (e) => {
|
||||
const content = Layout.vertical({layout: [self.selector, self.opacitySettingsContent]});
|
||||
self.update({content})
|
||||
@@ -86,7 +86,7 @@ import { Form } from "../Widgets/Form.js";
|
||||
monochrome: true,
|
||||
url: pixelHistIconUrl
|
||||
},
|
||||
tooltip: {content: 'Pixel cutouts', position: {direction: 'bottom'}},
|
||||
tooltip: {content: 'Cutouts', position: {direction: 'bottom'}},
|
||||
action: (e) => {
|
||||
const content = Layout.vertical({layout: [self.selector, self.pixelSettingsContent]});
|
||||
self.update({content})
|
||||
@@ -241,10 +241,25 @@ import { Form } from "../Widgets/Form.js";
|
||||
name: 'cmap',
|
||||
value: 'native',
|
||||
options: aladin.getListOfColormaps(),
|
||||
change: (e, cmapSelector) => {
|
||||
change: (e) => {
|
||||
self.options.layer.setColormap(e.target.value)
|
||||
},
|
||||
}]
|
||||
},
|
||||
{
|
||||
label: 'reverse:',
|
||||
type: 'checkbox',
|
||||
name: 'reverse',
|
||||
cssStyle: {
|
||||
// so that it takes as much space as it can
|
||||
flex: "0 0 1",
|
||||
},
|
||||
checked: false,
|
||||
change: (e) => {
|
||||
let checked = colorSettingsContent.getInput("reverse").checked
|
||||
self.options.layer.setColormap(null, {reversed: checked})
|
||||
}
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
super({
|
||||
@@ -265,12 +280,11 @@ import { Form } from "../Widgets/Form.js";
|
||||
this.luminositySettingsContent = luminositySettingsContent;
|
||||
}
|
||||
|
||||
update(options) {
|
||||
if (options.layer) {
|
||||
let hips = options.layer;
|
||||
let colorCfg = hips.getColorCfg();
|
||||
_update(layer) {
|
||||
let colorCfg = layer.getColorCfg();
|
||||
let stretch = colorCfg.stretch;
|
||||
let colormap = colorCfg.getColormap();
|
||||
let reversed = colorCfg.getReversed();
|
||||
|
||||
let [minCut, maxCut] = colorCfg.getCuts();
|
||||
this.pixelSettingsContent.set('mincut', +minCut.toFixed(4))
|
||||
@@ -279,19 +293,26 @@ import { Form } from "../Widgets/Form.js";
|
||||
let fmtInput = this.pixelSettingsContent.getInput('fmt')
|
||||
|
||||
fmtInput.innerHTML = '';
|
||||
for (const option of hips.formats) {
|
||||
for (const option of layer.formats) {
|
||||
fmtInput.innerHTML += "<option>" + option + "</option>";
|
||||
}
|
||||
fmtInput.value = hips.imgFormat;
|
||||
fmtInput.value = layer.imgFormat;
|
||||
|
||||
this.colorSettingsContent.set('cmap', colormap);
|
||||
this.opacitySettingsContent.set('opacity', hips.getOpacity());
|
||||
this.colorSettingsContent.set('reverse', reversed);
|
||||
|
||||
this.opacitySettingsContent.set('opacity', layer.getOpacity());
|
||||
this.luminositySettingsContent.set('brightness', colorCfg.getBrightness());
|
||||
this.luminositySettingsContent.set('contrast', colorCfg.getContrast());
|
||||
this.luminositySettingsContent.set('gamma', colorCfg.getGamma());
|
||||
this.luminositySettingsContent.set('saturation', colorCfg.getSaturation());
|
||||
}
|
||||
|
||||
update(options) {
|
||||
if (options.layer) {
|
||||
this._update(options.layer)
|
||||
}
|
||||
|
||||
super.update(options)
|
||||
}
|
||||
|
||||
@@ -300,28 +321,7 @@ import { Form } from "../Widgets/Form.js";
|
||||
const hips = e.detail.layer;
|
||||
let selectedLayer = this.options.layer;
|
||||
if (selectedLayer && hips.layer === selectedLayer.layer) {
|
||||
let colorCfg = hips.getColorCfg();
|
||||
let stretch = colorCfg.stretch;
|
||||
let colormap = colorCfg.getColormap();
|
||||
|
||||
let [minCut, maxCut] = colorCfg.getCuts();
|
||||
this.pixelSettingsContent.set('mincut', +minCut.toFixed(4))
|
||||
this.pixelSettingsContent.set('maxcut', +maxCut.toFixed(4))
|
||||
this.pixelSettingsContent.set('stretch', stretch)
|
||||
let fmtInput = this.pixelSettingsContent.getInput('fmt')
|
||||
|
||||
fmtInput.innerHTML = '';
|
||||
for (const option of hips.formats) {
|
||||
fmtInput.innerHTML += "<option>" + option + "</option>";
|
||||
}
|
||||
fmtInput.value = hips.imgFormat;
|
||||
|
||||
this.colorSettingsContent.set('cmap', colormap);
|
||||
this.opacitySettingsContent.set('opacity', hips.getOpacity());
|
||||
this.luminositySettingsContent.set('brightness', colorCfg.getBrightness());
|
||||
this.luminositySettingsContent.set('contrast', colorCfg.getContrast());
|
||||
this.luminositySettingsContent.set('gamma', colorCfg.getGamma());
|
||||
this.luminositySettingsContent.set('saturation', colorCfg.getSaturation());
|
||||
this._update(hips)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -73,9 +73,11 @@ export class Input extends DOMElement {
|
||||
|
||||
this.el.checked = this.options.checked;
|
||||
|
||||
if (this.options.click) {
|
||||
// for checkbox widgets, we authorize calling the callback name click or change
|
||||
let action = this.options.click || this.options.change;
|
||||
if (action) {
|
||||
this.el.removeEventListener('click', this.action);
|
||||
this.action = this.options.click;
|
||||
this.action = action;
|
||||
|
||||
this.el.addEventListener('click', this.action);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user