mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2026-01-04 00:57:17 -08:00
Compare commits
2 Commits
hover-effe
...
SAMP
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e14b2694ca | ||
|
|
e0c2288306 |
@@ -8,7 +8,7 @@
|
|||||||
import A from '../src/js/A.js';
|
import A from '../src/js/A.js';
|
||||||
let aladin;
|
let aladin;
|
||||||
A.init.then(() => {
|
A.init.then(() => {
|
||||||
aladin = A.aladin('#aladin-lite-div', {projection: "TAN", target: '15 16 57.636 -60 55 7.49', showCooGrid: true, fov: 90, fullScreen: true});
|
aladin = A.aladin('#aladin-lite-div', {projection: "TAN", target: '15 16 57.636 -60 55 7.49', samp: true, showCooGrid: true, fov: 90, fullScreen: true});
|
||||||
|
|
||||||
var moc_0_99 = A.MOCFromURL("./gw/gw_0.9.fits",{ name: "GW 90%", color: "#ff0000", opacity: 0.7, lineWidth: 5, perimeter: true});
|
var moc_0_99 = A.MOCFromURL("./gw/gw_0.9.fits",{ name: "GW 90%", color: "#ff0000", opacity: 0.7, lineWidth: 5, perimeter: true});
|
||||||
var moc_0_95 = A.MOCFromURL("./gw/gw_0.6.fits",{ name: "GW 60%", color: "#00ff00", opacity: 0.8, lineWidth: 5, perimeter: true});
|
var moc_0_95 = A.MOCFromURL("./gw/gw_0.6.fits",{ name: "GW 60%", color: "#00ff00", opacity: 0.8, lineWidth: 5, perimeter: true});
|
||||||
|
|||||||
@@ -165,8 +165,6 @@ A.MOCFromJSON = function (jsonMOC, options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// TODO: try first without proxy, and then with, if param useProxy not set
|
|
||||||
// API
|
|
||||||
A.catalogFromURL = function (url, options, successCallback, errorCallback, useProxy) {
|
A.catalogFromURL = function (url, options, successCallback, errorCallback, useProxy) {
|
||||||
var catalog = A.catalog(options);
|
var catalog = A.catalog(options);
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ import { ALEvent } from "./events/ALEvent.js";
|
|||||||
import { Color } from './Color.js';
|
import { Color } from './Color.js';
|
||||||
import { ImageFITS } from "./ImageFITS.js";
|
import { ImageFITS } from "./ImageFITS.js";
|
||||||
import { DefaultActionsForContextMenu } from "./DefaultActionsForContextMenu.js";
|
import { DefaultActionsForContextMenu } from "./DefaultActionsForContextMenu.js";
|
||||||
|
import { SAMPConnector } from "./vo/samp.js";
|
||||||
import A from "./A.js";
|
import A from "./A.js";
|
||||||
|
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
@@ -471,6 +472,13 @@ export let Aladin = (function () {
|
|||||||
this.contextMenu = new ContextMenu(this);
|
this.contextMenu = new ContextMenu(this);
|
||||||
this.contextMenu.attachTo(this.view.catalogCanvas, DefaultActionsForContextMenu.getDefaultActions(this));
|
this.contextMenu.attachTo(this.view.catalogCanvas, DefaultActionsForContextMenu.getDefaultActions(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.samp) {
|
||||||
|
this.samp = new SAMPConnector(this);
|
||||||
|
ALEvent.SAMP_AVAILABILITY.listenedBy(this.aladinDiv, function (e) {
|
||||||
|
console.log('is hub running samp', e.detail.isHubRunning)
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**** CONSTANTS ****/
|
/**** CONSTANTS ****/
|
||||||
@@ -504,6 +512,7 @@ export let Aladin = (function () {
|
|||||||
reticleColor: "rgb(178, 50, 178)",
|
reticleColor: "rgb(178, 50, 178)",
|
||||||
reticleSize: 22,
|
reticleSize: 22,
|
||||||
log: true,
|
log: true,
|
||||||
|
samp: true,
|
||||||
allowFullZoomout: false,
|
allowFullZoomout: false,
|
||||||
realFullscreen: false,
|
realFullscreen: false,
|
||||||
showAllskyRing: false,
|
showAllskyRing: false,
|
||||||
|
|||||||
@@ -370,7 +370,6 @@ export let View = (function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.computeNorder();
|
this.computeNorder();
|
||||||
this.redraw();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var pixelateCanvasContext = function (ctx, pixelateFlag) {
|
var pixelateCanvasContext = function (ctx, pixelateFlag) {
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ export class ALEvent {
|
|||||||
|
|
||||||
static GRAPHIC_OVERLAY_LAYER_CHANGED = new ALEvent("AL:GraphicOverlayLayer.changed");
|
static GRAPHIC_OVERLAY_LAYER_CHANGED = new ALEvent("AL:GraphicOverlayLayer.changed");
|
||||||
|
|
||||||
|
static SAMP_AVAILABILITY = new ALEvent("AL:samp.started");
|
||||||
|
|
||||||
constructor(name) {
|
constructor(name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|||||||
1319
src/js/libs/samp.js
Normal file
1319
src/js/libs/samp.js
Normal file
File diff suppressed because it is too large
Load Diff
180
src/js/vo/samp.js
Normal file
180
src/js/vo/samp.js
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
// Copyright 2013 - UDS/CNRS
|
||||||
|
// The Aladin Lite program is distributed under the terms
|
||||||
|
// of the GNU General Public License version 3.
|
||||||
|
//
|
||||||
|
// This file is part of Aladin Lite.
|
||||||
|
//
|
||||||
|
// Aladin Lite is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, version 3 of the License.
|
||||||
|
//
|
||||||
|
// Aladin Lite is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// The GNU General Public License is available in COPYING file
|
||||||
|
// along with Aladin Lite.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Aladin Lite project
|
||||||
|
*
|
||||||
|
* File vo/samp.js
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Author: Matthieu Baumann [CDS, matthieu.baumann@astro.unistra.fr]
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
import { ALEvent } from "../events/ALEvent";
|
||||||
|
import { samp } from '../libs/samp';
|
||||||
|
|
||||||
|
export class SAMPConnector {
|
||||||
|
constructor(aladin) {
|
||||||
|
// Define listeners
|
||||||
|
let cc = new samp.ClientTracker();
|
||||||
|
let callHandler = cc.callHandler;
|
||||||
|
|
||||||
|
callHandler["script.aladin.send"] = function(senderId, message, isCall) {
|
||||||
|
var params = message["samp.params"];
|
||||||
|
aladin.setBaseImageLayer(params["url"])
|
||||||
|
};
|
||||||
|
|
||||||
|
callHandler["coord.pointAt.sky"] = function(senderId, message, isCall) {
|
||||||
|
var params = message["samp.params"];
|
||||||
|
|
||||||
|
aladin.gotoRaDec(+params["ra"], +params["dec"])
|
||||||
|
};
|
||||||
|
|
||||||
|
callHandler["coverage.load.moc.fits"] = function(senderId, message, isCall) {
|
||||||
|
var params = message["samp.params"];
|
||||||
|
|
||||||
|
let name = params["name"];
|
||||||
|
let moc = A.MOCFromURL(params["url"], {name: name, lineWidth: 3});
|
||||||
|
aladin.addMOC(moc);
|
||||||
|
};
|
||||||
|
|
||||||
|
callHandler["image.load.fits"] = function(senderId, message, isCall) {
|
||||||
|
let params = message["samp.params"];
|
||||||
|
|
||||||
|
let url = params["url"];
|
||||||
|
let name = params["name"];
|
||||||
|
const image = aladin.createImageFITS(url, name, options, (e) => window.alert(e));
|
||||||
|
|
||||||
|
aladin.setOverlayImageLayer(image, name);
|
||||||
|
};
|
||||||
|
|
||||||
|
callHandler["table.load.votable"] = function(senderId, message, isCall) {
|
||||||
|
let params = message["samp.params"];
|
||||||
|
|
||||||
|
let url = params["url"];
|
||||||
|
let name = params["name"];
|
||||||
|
|
||||||
|
let cat = A.catalogFromURL(
|
||||||
|
url,
|
||||||
|
{name: name, onClick: 'showTable'},
|
||||||
|
null,
|
||||||
|
(e) => window.alert(e)
|
||||||
|
);
|
||||||
|
aladin.addCatalog(cat)
|
||||||
|
};
|
||||||
|
|
||||||
|
let subs = cc.calculateSubscriptions();
|
||||||
|
let meta = {
|
||||||
|
"samp.name": "Aladin Lite",
|
||||||
|
"samp.description": "Aladin Lite web visualizer SAMP connector"
|
||||||
|
};
|
||||||
|
// Arrange for document to be adjusted for presence of hub every 2 sec.
|
||||||
|
this.connector = new samp.Connector("Aladin Lite", meta, cc, subs);
|
||||||
|
window.addEventListener('load', (e) => {
|
||||||
|
this.connector.onHubAvailability((isHubRunning) => {
|
||||||
|
// Communicate to Aladin Lite
|
||||||
|
ALEvent.SAMP_AVAILABILITY.dispatchedTo(aladin.aladinDiv, { isHubRunning: isHubRunning } );
|
||||||
|
}, 2000);
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener('unload', (e) => {
|
||||||
|
this.connector.unregister();
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO put that in a button
|
||||||
|
//this.connector.register();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Broadcasts a message given a hub connection.
|
||||||
|
_send(mtype, params) {
|
||||||
|
// Provides execution of a SAMP operation with register-on-demand.
|
||||||
|
this.connector.runWithConnection(
|
||||||
|
(connection) => {
|
||||||
|
let msg = new samp.Message(mtype, params);
|
||||||
|
connection.notifyAll([msg]);
|
||||||
|
},
|
||||||
|
(e) => {
|
||||||
|
window.alert(e)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a VOTable by url
|
||||||
|
* @param {String} url - URL of the VOTable document to load
|
||||||
|
* @param {String} [tableId] - Identifier which may be used to refer to the loaded table in subsequent messages
|
||||||
|
* @param {String} [name] - Name which may be used to label the loaded table in the application GUI
|
||||||
|
*/
|
||||||
|
loadVOTable(url, tableId, name) {
|
||||||
|
this._send("table.load.votable", {
|
||||||
|
url: url,
|
||||||
|
"table-id": tableId,
|
||||||
|
name: name
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a fits image by url
|
||||||
|
* @param {String} url - URL of the FITS image to load
|
||||||
|
* @param {String} [imageId] - Identifier which may be used to refer to the loaded image in subsequent messages
|
||||||
|
* @param {String} [name] - Name which may be used to label the loaded image in the application GUI
|
||||||
|
*/
|
||||||
|
loadImageFITS(url, imageId, name) {
|
||||||
|
this._send("image.load.fits", {
|
||||||
|
"url": url,
|
||||||
|
"image-id": imageId,
|
||||||
|
"name": name
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a Multi-Order-Coverage FITS file
|
||||||
|
* @param {String} url - URL of a FITS file containing the MOC to load
|
||||||
|
* @param {String} [coverageId] - Identifier which may be used to refer to the loaded coverage specification in subsequent messages
|
||||||
|
* @param {String} [name] - Name which may be used to label the loaded image in the application GUI
|
||||||
|
*/
|
||||||
|
loadMocFITS(url, coverageId, name) {
|
||||||
|
this._send("coverage.load.moc.fits", {
|
||||||
|
"url": url,
|
||||||
|
"coverage-id": coverageId,
|
||||||
|
"name": name
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a HiPS by an url
|
||||||
|
* @param {String} url - base URL for the HiPS to load
|
||||||
|
*/
|
||||||
|
loadHiPS(url) {
|
||||||
|
const cmd = 'load ' + url;
|
||||||
|
this._send("script.aladin.send", { "script": cmd })
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a ra, dec position to the hub
|
||||||
|
* @param {Float} ra - right ascension in degrees
|
||||||
|
* @param {Float} dec - declination in degrees
|
||||||
|
*/
|
||||||
|
centerAtRaDec(ra, dec) {
|
||||||
|
this._send("coord.pointAt.sky", { "ra": ra.toString(), "dec": dec.toString() })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user