diff --git a/examples/al-multi-catalog-table.html b/examples/al-multi-catalog-table.html
index 403b3869..5e631784 100644
--- a/examples/al-multi-catalog-table.html
+++ b/examples/al-multi-catalog-table.html
@@ -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);
diff --git a/src/js/Aladin.js b/src/js/Aladin.js
index bbf08f59..f5c909ea 100644
--- a/src/js/Aladin.js
+++ b/src/js/Aladin.js
@@ -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 = "ObsCore:" + url;
diff --git a/src/js/Catalog.js b/src/js/Catalog.js
index c4426da5..4811f091 100644
--- a/src/js/Catalog.js
+++ b/src/js/Catalog.js
@@ -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
diff --git a/src/js/MeasurementTable.js b/src/js/MeasurementTable.js
index 7fffdf86..05026547 100644
--- a/src/js/MeasurementTable.js
+++ b/src/js/MeasurementTable.js
@@ -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";
};
diff --git a/src/js/Source.js b/src/js/Source.js
index ab7bf736..9f3bfc40 100644
--- a/src/js/Source.js
+++ b/src/js/Source.js
@@ -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') {
diff --git a/src/js/View.js b/src/js/View.js
index e95e29c2..71a98aaa 100644
--- a/src/js/View.js
+++ b/src/js/View.js
@@ -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;
diff --git a/src/js/vo/Datalink.js b/src/js/vo/Datalink.js
index 13c34842..985a500b 100644
--- a/src/js/vo/Datalink.js
+++ b/src/js/vo/Datalink.js
@@ -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()
+ }
+ },
+ ]);
}
)
};
diff --git a/src/js/vo/Obscore.js b/src/js/vo/Obscore.js
index 83d22c05..6a711ed4 100644
--- a/src/js/vo/Obscore.js
+++ b/src/js/vo/Obscore.js
@@ -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