mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2025-12-12 15:49:18 -08:00
Add option for manual selection logic
This commit is contained in:
committed by
Matthieu Baumann
parent
35f13fe1f0
commit
42ece4fba1
@@ -146,6 +146,7 @@ import { Polyline } from "./shapes/Polyline";
|
||||
* @property {boolean} [samp=false] - Whether to enable SAMP (Simple Application Messaging Protocol).
|
||||
* @property {boolean} [realFullscreen=false] - Whether to use real fullscreen mode.
|
||||
* @property {boolean} [pixelateCanvas=true] - Whether to pixelate the canvas.
|
||||
* @property {boolean} [manualSelection=false] - When set to true, no selection will be performed, only events will be generated.
|
||||
* @example
|
||||
* let aladin = A.aladin({
|
||||
target: 'galactic center',
|
||||
@@ -712,6 +713,7 @@ export let Aladin = (function () {
|
||||
samp: false,
|
||||
realFullscreen: false,
|
||||
pixelateCanvas: true,
|
||||
manualSelection: false
|
||||
};
|
||||
|
||||
// realFullscreen: AL div expands not only to the size of its parent, but takes the whole available screen estate
|
||||
|
||||
@@ -208,6 +208,7 @@ export let View = (function () {
|
||||
this.changeFrame(cooFrame);
|
||||
|
||||
this.selector = new Selector(this, this.options.selector);
|
||||
this.manualSelection = (this.options && this.options.manualSelection) || false;
|
||||
|
||||
// current reference image survey displayed
|
||||
this.imageLayers = new Map();
|
||||
@@ -577,8 +578,8 @@ export let View = (function () {
|
||||
const xymouse = Utils.relMouseCoords(e);
|
||||
|
||||
// deselect all the selected sources with Select panel
|
||||
//view.unselectObjects()
|
||||
|
||||
view.unselectObjects();
|
||||
|
||||
try {
|
||||
const [lon, lat] = view.aladin.pix2world(xymouse.x, xymouse.y, 'icrs');
|
||||
view.pointTo(lon, lat);
|
||||
@@ -620,6 +621,8 @@ export let View = (function () {
|
||||
var handleSelect = function(xy, tolerance) {
|
||||
tolerance = tolerance || 5;
|
||||
var objs = view.closestObjects(xy.x, xy.y, tolerance);
|
||||
|
||||
view.unselectObjects();
|
||||
|
||||
if (objs) {
|
||||
var objClickedFunction = view.aladin.callbacksByEventName['objectClicked'];
|
||||
@@ -644,11 +647,11 @@ export let View = (function () {
|
||||
footprintClickedFunction(o, xy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//view.selectObjects([objs]);
|
||||
// rewrite objs
|
||||
objs = Array.from(Object.values(objsByCats));
|
||||
view.selectObjects(objs);
|
||||
view.lastClickedObject = objs;
|
||||
|
||||
} else {
|
||||
@@ -1447,6 +1450,10 @@ export let View = (function () {
|
||||
};
|
||||
|
||||
View.prototype.unselectObjects = function() {
|
||||
if (this.manualSelection) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.aladin.measurementTable.hide();
|
||||
|
||||
if (this.selection) {
|
||||
@@ -1467,8 +1474,12 @@ export let View = (function () {
|
||||
|
||||
View.prototype.selectObjects = function(selection) {
|
||||
// unselect the previous selection
|
||||
//this.unselectObjects();
|
||||
if (this.manualSelection) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.unselectObjects();
|
||||
|
||||
if (Array.isArray(selection)) {
|
||||
this.selection = selection;
|
||||
} else {
|
||||
|
||||
@@ -288,8 +288,8 @@ export let Circle = (function() {
|
||||
// From StackOverflow: https://stackoverflow.com/questions/401847/circle-rectangle-collision-detection-intersection
|
||||
Circle.prototype.intersectsBBox = function(x, y, w, h) {
|
||||
const circleDistance = {
|
||||
x: abs(this.center.x - x),
|
||||
y: abs(this.center.y - y)
|
||||
x: Math.abs(this.center.x - x),
|
||||
y: Math.abs(this.center.y - y)
|
||||
};
|
||||
|
||||
if (circleDistance.x > (w/2 + this.radius)) { return false; }
|
||||
|
||||
Reference in New Issue
Block a user