mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2025-12-24 20:10:30 -08:00
previous next states for obscore table
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
aladin = A.aladin('#aladin-lite-div', {target: 'M 45', fov: 5});
|
||||
|
||||
const cat = A.catalogFromVizieR('I/311/hip2', 'M 45', 5, {onClick: 'showTable'});
|
||||
const cat2 = A.catalogFromVizieR('I/311/hip2', 'M 45', 5, {onClick: 'showTable'});
|
||||
const cat2 = A.catalogFromVizieR('I/312/sample', 'M 45', 0.5, {onClick: 'showTable'});
|
||||
|
||||
aladin.addCatalog(cat);
|
||||
aladin.addCatalog(cat2);
|
||||
|
||||
@@ -62,19 +62,15 @@ import { ImageFITS } from "./ImageFITS.js";
|
||||
import { SimbadPointer } from "./SimbadPointer.js";
|
||||
import { PlanetaryFeaturesPointer } from "./PlanetaryFeaturesPointer.js";
|
||||
import { DefaultActionsForContextMenu } from "./DefaultActionsForContextMenu.js";
|
||||
import { Obscore } from "./vo/Obscore.js";
|
||||
import { ObsCore } from "./vo/ObsCore.js";
|
||||
|
||||
import $ from 'jquery';
|
||||
|
||||
// Import aladin css inside the project
|
||||
import './../css/aladin.css';
|
||||
import { VOTable } from "./vo/VOTable.js";
|
||||
|
||||
|
||||
export let Aladin = (function () {
|
||||
|
||||
|
||||
|
||||
// Constructor
|
||||
var Aladin = function (aladinDiv, requestedOptions) {
|
||||
// check that aladinDiv exists, stop immediately otherwise
|
||||
@@ -1850,7 +1846,7 @@ A.catalogFromURL = function (url, options, successCallback, useProxy) {
|
||||
function (sources, footprints, fields) {
|
||||
catalog.setFields(fields);
|
||||
|
||||
if (fields.subtype === "ObsCore") {
|
||||
if (catalog.isObsCore()) {
|
||||
// The fields corresponds to obscore ones
|
||||
// Set the name of the catalog to be ObsCore:<catalog name>
|
||||
catalog.name = "ObsCore:" + url;
|
||||
|
||||
@@ -34,8 +34,6 @@ import { Color } from "./Color.js"
|
||||
import { Utils } from "./Utils.js";
|
||||
import { AladinUtils } from "./AladinUtils.js";
|
||||
import { Coo } from "./libs/astro/coo.js";
|
||||
import { ALEvent } from "./events/ALEvent.js";
|
||||
import { Obscore } from "./vo/ObsCore.js";
|
||||
import { VOTable } from "./vo/VOTable.js";
|
||||
|
||||
import $ from 'jquery';
|
||||
@@ -400,6 +398,10 @@ export let Catalog = (function() {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
Catalog.prototype.isObsCore = function() {
|
||||
return this.fields.subtype === "ObsCore";
|
||||
}
|
||||
|
||||
// API
|
||||
//
|
||||
// create sources from a 2d array and add them to the catalog
|
||||
|
||||
@@ -41,6 +41,10 @@ export let MeasurementTable = (function() {
|
||||
let mainDiv = document.createElement('div');
|
||||
mainDiv.setAttribute("class", "aladin-measurement-div");
|
||||
this.element = mainDiv;
|
||||
|
||||
this.savedTablesIdx = 0;
|
||||
this.savedTables = [];
|
||||
|
||||
aladinLiteDiv.appendChild(this.element);
|
||||
}
|
||||
|
||||
@@ -90,13 +94,101 @@ export let MeasurementTable = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
MeasurementTable.prototype.showPreviousMeasurement = function() {
|
||||
this.savedTablesIdx--;
|
||||
if (this.savedTablesIdx < 0) {
|
||||
this.savedTablesIdx = 0;
|
||||
}
|
||||
|
||||
let tables = this.savedTables[this.savedTablesIdx];
|
||||
|
||||
if (tables) {
|
||||
this.update(tables);
|
||||
this.updateStateNavigation();
|
||||
}
|
||||
}
|
||||
|
||||
MeasurementTable.prototype.showNextMeasurement = function() {
|
||||
this.savedTablesIdx++;
|
||||
if (this.savedTablesIdx >= this.savedTables.length) {
|
||||
this.savedTablesIdx = this.savedTables.length - 1;
|
||||
}
|
||||
|
||||
let tables = this.savedTables[this.savedTablesIdx];
|
||||
|
||||
if (tables) {
|
||||
this.update(tables);
|
||||
this.updateStateNavigation();
|
||||
}
|
||||
}
|
||||
|
||||
// show measurement associated with a given source
|
||||
MeasurementTable.prototype.showMeasurement = function(tables) {
|
||||
MeasurementTable.prototype.showMeasurement = function(tables, options) {
|
||||
if (tables.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.update(tables);
|
||||
|
||||
if (options && options["save"]) {
|
||||
this.saveState();
|
||||
|
||||
this.updateStateNavigation();
|
||||
}
|
||||
};
|
||||
|
||||
MeasurementTable.prototype.updateStateNavigation = function() {
|
||||
// update the previous/next buttons
|
||||
let tabsElement = this.element.querySelector(".tabs");
|
||||
if (this.savedTables.length >= 2) {
|
||||
/// Create previous tab
|
||||
let prevTableElement = document.createElement('button');
|
||||
prevTableElement.setAttribute('title', 'go to the previous table')
|
||||
if (this.savedTablesIdx == 0) {
|
||||
prevTableElement.disabled = true;
|
||||
}
|
||||
|
||||
prevTableElement.addEventListener(
|
||||
'click', () => this.showPreviousMeasurement(), false
|
||||
);
|
||||
|
||||
prevTableElement.innerText = '<';
|
||||
tabsElement.appendChild(prevTableElement);
|
||||
|
||||
/// Create next tab
|
||||
let nextTableElement = document.createElement('button');
|
||||
nextTableElement.setAttribute('title', 'go to the next table')
|
||||
|
||||
if (this.savedTables.length == 0 || this.savedTablesIdx == this.savedTables.length - 1) {
|
||||
nextTableElement.disabled = true;
|
||||
}
|
||||
|
||||
nextTableElement.addEventListener(
|
||||
'click', () => this.showNextMeasurement(), false
|
||||
);
|
||||
|
||||
nextTableElement.innerText = '>';
|
||||
tabsElement.appendChild(nextTableElement);
|
||||
}
|
||||
};
|
||||
|
||||
MeasurementTable.prototype.saveState = function() {
|
||||
if (this.savedTables.length === 0) {
|
||||
this.savedTables.push(this.tables);
|
||||
} else {
|
||||
if (this.tables !== this.savedTables[this.savedTablesIdx]) {
|
||||
// Remove all the tables past to the current one
|
||||
this.savedTables = this.savedTables.slice(0, this.savedTablesIdx + 1);
|
||||
// Save the current tables
|
||||
this.savedTables.push(this.tables);
|
||||
this.savedTablesIdx = this.savedTables.length - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MeasurementTable.prototype.update = function(tables) {
|
||||
this.tables = tables;
|
||||
|
||||
this.curTableIdx = 0;
|
||||
|
||||
let table = tables[this.curTableIdx];
|
||||
@@ -122,12 +214,13 @@ export let MeasurementTable = (function() {
|
||||
this.updateRows();
|
||||
|
||||
this.show();
|
||||
};
|
||||
}
|
||||
|
||||
MeasurementTable.prototype.createTabs = function() {
|
||||
let tabsElement = document.createElement('div')
|
||||
tabsElement.setAttribute('class', 'tabs');
|
||||
|
||||
/// Create catalog tabs
|
||||
let tabsButtonElement = [];
|
||||
|
||||
let self = this;
|
||||
@@ -183,6 +276,10 @@ export let MeasurementTable = (function() {
|
||||
};
|
||||
|
||||
MeasurementTable.prototype.hide = function() {
|
||||
this.savedTables = [];
|
||||
this.savedTablesIdx = 0;
|
||||
this.curTableIdx = 0;
|
||||
|
||||
this.element.style.visibility = "hidden";
|
||||
};
|
||||
|
||||
|
||||
@@ -106,7 +106,15 @@ export let Source = (function() {
|
||||
'name': this.catalog.name,
|
||||
'color': this.catalog.color
|
||||
};
|
||||
view.aladin.measurementTable.showMeasurement([singleSourceTable]);
|
||||
|
||||
let options = {};
|
||||
if (this.catalog.isObsCore()) {
|
||||
// If the source is obscore, save the table state inside the measurement table
|
||||
// This is used to go back from a possible datalink table to the obscore one
|
||||
options["save"] = true;
|
||||
}
|
||||
|
||||
view.aladin.measurementTable.showMeasurement([singleSourceTable], options);
|
||||
}
|
||||
else if (this.catalog.onClick=='showPopup') {
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@ export let View = (function () {
|
||||
const files = Utils.getDroppedFilesHandler(event);
|
||||
|
||||
files.forEach((file) => {
|
||||
console.log(file.name)
|
||||
const url = URL.createObjectURL(file);
|
||||
|
||||
// Consider other cases
|
||||
@@ -570,6 +569,8 @@ export let View = (function () {
|
||||
} // end of "if (view.dragging) ... "
|
||||
|
||||
if (selectionHasEnded) {
|
||||
view.deselectObjects()
|
||||
|
||||
const selectedObjects = view.getObjectsInBBox(
|
||||
view.selectStartCoo.x,
|
||||
view.selectStartCoo.y,
|
||||
@@ -582,7 +583,6 @@ export let View = (function () {
|
||||
});
|
||||
|
||||
if (selectedObjects.length > 0) {
|
||||
console.log(selectedObjects)
|
||||
let tables = selectedObjects.map((objList) => {
|
||||
// Get the catalog containing that list of objects
|
||||
let catalog = objList[0].catalog;
|
||||
|
||||
@@ -78,14 +78,29 @@ export let Datalink = (function() {
|
||||
aladinInstance.setOverlayImageLayer(image, Utils.uuidv4())
|
||||
} else if (contentQualifier === "cube") {
|
||||
// fits cube
|
||||
console.warn("Cube not handled")
|
||||
console.warn("Cube not handled, only first slice downloaded")
|
||||
let image = aladinInstance.createImageFITS(url);
|
||||
aladinInstance.setOverlayImageLayer(image, Utils.uuidv4())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aladinInstance.measurementTable.showMeasurement([datalinkTable]);
|
||||
aladinInstance.measurementTable.showMeasurement([datalinkTable], { save: true });
|
||||
|
||||
aladinInstance.contextMenu.attachTo(aladinInstance.measurementTable.element, [
|
||||
{
|
||||
label: "Go back", action(o) {
|
||||
aladinInstance.measurementTable.showPreviousMeasurement()
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "Go Next", action(o) {
|
||||
aladinInstance.measurementTable.showNextMeasurement()
|
||||
}
|
||||
},
|
||||
]);
|
||||
}
|
||||
)
|
||||
};
|
||||
|
||||
@@ -205,7 +205,6 @@
|
||||
// A datalink response containing links to datasets or services attached to the current dataset
|
||||
case 'application/x-votable+xml;content=datalink':
|
||||
//Datalink.handleActions(url)
|
||||
console.log("jjj")
|
||||
Datalink.handleActions("datalink.xml", aladinInstance);
|
||||
break;
|
||||
// Any multidimensional regularly sampled FITS image or cube
|
||||
|
||||
Reference in New Issue
Block a user