mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2025-12-27 21:24:11 -08:00
Compare commits
2 Commits
develop
...
fix-circle
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac4af8fb18 | ||
|
|
279f93c4ba |
@@ -45,7 +45,6 @@ export let DefaultActionsForContextMenu = (function () {
|
|||||||
const a = aladinInstance;
|
const a = aladinInstance;
|
||||||
|
|
||||||
const selectObjects = (selection) => {
|
const selectObjects = (selection) => {
|
||||||
console.log(selection)
|
|
||||||
a.view.selectObjects(selection);
|
a.view.selectObjects(selection);
|
||||||
};
|
};
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ export let Footprint= (function() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return this.shapes.some((shape) => shape.intersectsBBox(x, y, w, h, view));
|
||||||
};
|
};
|
||||||
|
|
||||||
return Footprint;
|
return Footprint;
|
||||||
|
|||||||
@@ -135,10 +135,12 @@ export class Selector {
|
|||||||
}
|
}
|
||||||
// footprints
|
// footprints
|
||||||
overlayItems = cat.getFootprints();
|
overlayItems = cat.getFootprints();
|
||||||
|
|
||||||
if (overlayItems) {
|
if (overlayItems) {
|
||||||
const {x, y, w, h} = selection.bbox();
|
const {x, y, w, h} = selection.bbox();
|
||||||
for (var l = 0; l < overlayItems.length; l++) {
|
for (var l = 0; l < overlayItems.length; l++) {
|
||||||
f = overlayItems[l];
|
f = overlayItems[l];
|
||||||
|
|
||||||
if (f.intersectsBBox(x, y, w, h, view)) {
|
if (f.intersectsBBox(x, y, w, h, view)) {
|
||||||
objListPerCatalog.push(f);
|
objListPerCatalog.push(f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -322,10 +322,17 @@ export let Circle = (function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// From StackOverflow: https://stackoverflow.com/questions/401847/circle-rectangle-collision-detection-intersection
|
// From StackOverflow: https://stackoverflow.com/questions/401847/circle-rectangle-collision-detection-intersection
|
||||||
Circle.prototype.intersectsBBox = function(x, y, w, h) {
|
Circle.prototype.intersectsBBox = function(x, y, w, h, view) {
|
||||||
|
var centerXyview = view.aladin.world2pix(this.centerRaDec[0], this.centerRaDec[1]);
|
||||||
|
if (!centerXyview) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// compute the absolute distance between the middle of the bbox
|
||||||
|
// and the center of the circle
|
||||||
const circleDistance = {
|
const circleDistance = {
|
||||||
x: Math.abs(this.center.x - x),
|
x: Math.abs(centerXyview[0] - (x + w/2)),
|
||||||
y: Math.abs(this.center.y - y)
|
y: Math.abs(centerXyview[1] - (y + h/2))
|
||||||
};
|
};
|
||||||
|
|
||||||
if (circleDistance.x > (w/2 + this.radius)) { return false; }
|
if (circleDistance.x > (w/2 + this.radius)) { return false; }
|
||||||
|
|||||||
@@ -346,6 +346,7 @@ export let Ellipse = (function() {
|
|||||||
|
|
||||||
Ellipse.prototype.intersectsBBox = function(x, y, w, h) {
|
Ellipse.prototype.intersectsBBox = function(x, y, w, h) {
|
||||||
// todo
|
// todo
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
return Ellipse;
|
return Ellipse;
|
||||||
|
|||||||
Reference in New Issue
Block a user