mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2026-03-12 21:23:10 -07:00
fix: setCuts with imageFormat, Add more HiPS search
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
|
||||
aladin.setBaseImageLayer(dss);
|
||||
|
||||
dss.setCuts(2, 10000);
|
||||
dss.setCuts(2, 100, 'jpeg');
|
||||
|
||||
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1117,6 +1117,14 @@ otherwise it fits its content options. If those are too big the select can go ou
|
||||
left: 0.2rem;
|
||||
}
|
||||
|
||||
.aladin-link {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.aladin-link:hover {
|
||||
color: greenyellow;
|
||||
}
|
||||
|
||||
.aladin-simbadPointer-control {
|
||||
position: absolute;
|
||||
top: 7.8rem;
|
||||
|
||||
@@ -1831,7 +1831,7 @@ export let Aladin = (function () {
|
||||
// Do not use proxy with CORS headers until we solve that: https://github.com/MattiasBuelens/wasm-streams/issues/20
|
||||
//url = Utils.handleCORSNotSameOrigin(url).href;
|
||||
|
||||
let imageOptions = {...options, successCallback, errorCallback};
|
||||
let imageOptions = {...options, imgFormat: 'fits', successCallback, errorCallback};
|
||||
let image = new Image(url, imageOptions);
|
||||
|
||||
return image;
|
||||
|
||||
@@ -59,9 +59,9 @@
|
||||
}
|
||||
|
||||
this.maxCut = {
|
||||
webp: 1.0,
|
||||
jpeg: 1.0,
|
||||
png: 1.0,
|
||||
webp: 255.0,
|
||||
jpeg: 255.0,
|
||||
png: 255.0,
|
||||
fits: undefined // wait the default value coming from the properties
|
||||
};
|
||||
if (options && Number.isFinite(options.maxCut)) {
|
||||
@@ -95,6 +95,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
let minCut = this.minCut[this.imgFormat]
|
||||
if (this.imgFormat !== "fits") {
|
||||
minCut /= 255.0
|
||||
}
|
||||
|
||||
let maxCut = this.maxCut[this.imgFormat]
|
||||
if (this.imgFormat !== "fits") {
|
||||
maxCut /= 255.0
|
||||
}
|
||||
|
||||
// Reset the whole meta object
|
||||
return {
|
||||
blendCfg: blend,
|
||||
@@ -107,8 +117,8 @@
|
||||
kContrast: this.kContrast,
|
||||
|
||||
stretch: this.stretch,
|
||||
minCut: this.minCut[this.imgFormat],
|
||||
maxCut: this.maxCut[this.imgFormat],
|
||||
minCut,
|
||||
maxCut,
|
||||
reversed: this.reversed,
|
||||
cmapName: this.colormap,
|
||||
}
|
||||
@@ -121,7 +131,7 @@
|
||||
|
||||
this.setColormap(options.colormap, options)
|
||||
|
||||
this.setCuts(options.minCut, options.maxCut)
|
||||
this.setCuts(options.minCut, options.maxCut, options.cutFormat)
|
||||
|
||||
this.setBrightness(options.brightness)
|
||||
this.setSaturation(options.saturation)
|
||||
@@ -249,18 +259,20 @@
|
||||
};
|
||||
|
||||
// Sets the cuts for the current image format
|
||||
ColorCfg.prototype.setCuts = function(minCut, maxCut) {
|
||||
ColorCfg.prototype.setCuts = function(minCut, maxCut, imgFormat) {
|
||||
imgFormat = imgFormat || this.imgFormat;
|
||||
|
||||
if (minCut instanceof Object) {
|
||||
// Mincut is given in the form of an javascript object with all the formats
|
||||
this.minCut = minCut
|
||||
this.minCut = {...this.minCut, ...minCut};
|
||||
} else if (minCut !== null && minCut !== undefined) {
|
||||
this.minCut[this.imgFormat] = minCut;
|
||||
this.minCut[imgFormat] = minCut;
|
||||
}
|
||||
|
||||
if (maxCut instanceof Object) {
|
||||
this.maxCut = maxCut;
|
||||
this.maxCut = {...this.maxCut, ...maxCut};
|
||||
} else if (maxCut !== null && maxCut !== undefined) {
|
||||
this.maxCut[this.imgFormat] = maxCut;
|
||||
this.maxCut[imgFormat] = maxCut;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ import { HiPSProperties } from "./HiPSProperties.js";
|
||||
import { Aladin } from "./Aladin.js";
|
||||
import { CooFrameEnum } from "./CooFrameEnum.js";
|
||||
import { Utils } from "./Utils"
|
||||
import { SpectraDisplayer } from "./SpectraDisplayer.js";
|
||||
|
||||
let PropertyParser = {};
|
||||
// Utilitary functions for parsing the properties and giving default values
|
||||
@@ -733,9 +732,16 @@ export let HiPS = (function () {
|
||||
*
|
||||
* @param {number} minCut - The low cut value to set for the HiPS.
|
||||
* @param {number} maxCut - The high cut value to set for the HiPS.
|
||||
* @param {string} [imgFormat] - The image format for which one wants to set the cuts. By default, the format used is the current imageFormat
|
||||
*/
|
||||
HiPS.prototype.setCuts = function (minCut, maxCut) {
|
||||
this.setOptions({minCut, maxCut})
|
||||
HiPS.prototype.setCuts = function (minCut, maxCut, imgFormat) {
|
||||
imgFormat = imgFormat?.toLowerCase();
|
||||
|
||||
if (imgFormat === "jpg") {
|
||||
imgFormat = "jpeg";
|
||||
}
|
||||
|
||||
this.setOptions({minCut, maxCut, cutFormat: imgFormat})
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -402,6 +402,7 @@ export let Image = (function () {
|
||||
|
||||
// Set the automatic computed cuts
|
||||
let [minCut, maxCut] = self.getCuts();
|
||||
|
||||
minCut = minCut || imageParams.min_cut;
|
||||
maxCut = maxCut || imageParams.max_cut;
|
||||
self.setCuts(
|
||||
|
||||
@@ -1300,7 +1300,7 @@ export let View = (function () {
|
||||
|
||||
if (!view.throttledTouchPadZoom) {
|
||||
view.throttledTouchPadZoom = () => {
|
||||
const factor = Utils.detectTrackPad(e) ? 1.06 : 1.2;
|
||||
const factor = Utils.detectTrackPad(e) ? 1.07 : 1.2;
|
||||
const currZoomFactor = view.zoom.isZooming ? view.zoom.finalZoom : view.zoomFactor;
|
||||
let newZoomFactor = view.delta > 0 ? currZoomFactor * factor : currZoomFactor / factor;
|
||||
|
||||
|
||||
@@ -219,11 +219,6 @@ import { TogglerActionButton } from "../Button/Toggler.js";
|
||||
value: 0.0,
|
||||
change: (e) => {
|
||||
let minCut = +e.target.value
|
||||
let imgFormat = self.options.layer.imgFormat;
|
||||
if (imgFormat !== "fits") {
|
||||
minCut /= 255.0;
|
||||
}
|
||||
|
||||
self.options.layer.setCuts(minCut, self.options.layer.getColorCfg().getCuts()[1])
|
||||
}
|
||||
},
|
||||
@@ -238,12 +233,6 @@ import { TogglerActionButton } from "../Button/Toggler.js";
|
||||
value: 1.0,
|
||||
change: (e) => {
|
||||
let maxCut = +e.target.value
|
||||
|
||||
let imgFormat = self.options.layer.imgFormat;
|
||||
if (imgFormat !== "fits") {
|
||||
maxCut /= 255.0;
|
||||
}
|
||||
|
||||
self.options.layer.setCuts(self.options.layer.getColorCfg().getCuts()[0], maxCut)
|
||||
}
|
||||
}]
|
||||
@@ -302,10 +291,6 @@ import { TogglerActionButton } from "../Button/Toggler.js";
|
||||
let reversed = colorCfg.getReversed();
|
||||
|
||||
let [minCut, maxCut] = colorCfg.getCuts();
|
||||
if (layer.imgFormat !== "fits") {
|
||||
minCut = Math.round(minCut * 255);
|
||||
maxCut = Math.round(maxCut * 255);
|
||||
}
|
||||
this.pixelSettingsContent.set('mincut', +minCut.toFixed(4))
|
||||
this.pixelSettingsContent.set('maxcut', +maxCut.toFixed(4))
|
||||
this.pixelSettingsContent.set('stretch', stretch)
|
||||
|
||||
@@ -781,6 +781,21 @@ export class OverlayStackBox extends Box {
|
||||
})
|
||||
);
|
||||
layout = layout.concat(this._createSurveysList());
|
||||
let self = this;
|
||||
const moreHiPSLink = document.createElement("a");
|
||||
moreHiPSLink.href = "#";
|
||||
moreHiPSLink.classList.add('aladin-link');
|
||||
moreHiPSLink.textContent = "More...";
|
||||
moreHiPSLink.title = "Open the survey browser"
|
||||
moreHiPSLink.addEventListener("click", (e) => {
|
||||
e.preventDefault();
|
||||
if (!self.hipsBrowser)
|
||||
self.hipsBrowser = new HiPSBrowserBox(aladin);
|
||||
|
||||
self.hipsBrowser._show({ position: { anchor: "center center" } });
|
||||
});
|
||||
layout.push(moreHiPSLink)
|
||||
|
||||
|
||||
return Layout.vertical({ layout });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user