From fc4459dc589a82ba9a2aaa3bdd7c71b9e8415816 Mon Sep 17 00:00:00 2001 From: Brent Miszalski Date: Mon, 17 Apr 2023 14:15:37 +1000 Subject: [PATCH 1/2] Allows HiPS cat to use shape function --- src/js/ProgressiveCat.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/js/ProgressiveCat.js b/src/js/ProgressiveCat.js index b3f6ad53..b5ebd24b 100644 --- a/src/js/ProgressiveCat.js +++ b/src/js/ProgressiveCat.js @@ -79,6 +79,16 @@ export let ProgressiveCat = (function() { // we cache the list of sources in each healpix tile. Key of the cache is norder+'-'+npix this.sourcesCache = new Utils.LRUCache(256); + //added to allow hips catalogue to also use shape functions + if (this.shape instanceof Image || this.shape instanceof HTMLCanvasElement) { + this.sourceSize = this.shape.width; + } + this._shapeIsFunction = false; // if true, the shape is a function drawing on the canvas + if ($.isFunction(this.shape)) { + this._shapeIsFunction = true; + } + + this.updateShape(options); this.maxOrderAllsky = 2; @@ -345,9 +355,16 @@ export let ProgressiveCat = (function() { return; } + if (this._shapeIsFunction) { + ctx.save(); + } + this.drawSources(this.order1Sources, ctx, width, height); this.drawSources(this.order2Sources, ctx, width, height); this.drawSources(this.order3Sources, ctx, width, height); + if (this._shapeIsFunction) { + ctx.restore(); + } if (!this.tilesInView) { return; From 4a3a8c0c4f63181e22a040a7c2a703a1be73cb01 Mon Sep 17 00:00:00 2001 From: Matthieu BAUMANN Date: Fri, 5 May 2023 12:45:19 +0200 Subject: [PATCH 2/2] remove need of jquery, move the restoring of the canvas after all drawSources have been called Co-authored-by: Brent Miszalski --- examples/al-catalog-hips-shape.html | 44 +++++++++++++++++++++++++++++ src/js/Catalog.js | 5 ---- src/js/ProgressiveCat.js | 18 +++++------- 3 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 examples/al-catalog-hips-shape.html diff --git a/examples/al-catalog-hips-shape.html b/examples/al-catalog-hips-shape.html new file mode 100644 index 00000000..9bff23dd --- /dev/null +++ b/examples/al-catalog-hips-shape.html @@ -0,0 +1,44 @@ + + + + + + +
+ +
+ + + + + + + + diff --git a/src/js/Catalog.js b/src/js/Catalog.js index c7975533..883e1b8d 100644 --- a/src/js/Catalog.js +++ b/src/js/Catalog.js @@ -576,12 +576,7 @@ export let Catalog = (function() { sourcesInsideView.push(s); } } - - //if (this.drawSource(s, ctx, width, height)) { - // sourcesInsideView.push(s); - //} }); - //this.view.wasm.drawSources(this.sources, ctx); return sourcesInsideView; }; diff --git a/src/js/ProgressiveCat.js b/src/js/ProgressiveCat.js index b5ebd24b..eed61d5a 100644 --- a/src/js/ProgressiveCat.js +++ b/src/js/ProgressiveCat.js @@ -84,15 +84,16 @@ export let ProgressiveCat = (function() { this.sourceSize = this.shape.width; } this._shapeIsFunction = false; // if true, the shape is a function drawing on the canvas - if ($.isFunction(this.shape)) { + if (typeof this.shape === 'function') { this._shapeIsFunction = true; } - this.updateShape(options); this.maxOrderAllsky = 2; this.isReady = false; + + this.tilesInView = []; }; // TODO: to be put higher in the class diagram, in a HiPS generic class @@ -222,8 +223,6 @@ export let ProgressiveCat = (function() { return sources; }; - //ProgressiveCat.prototype.updateShape = Catalog.prototype.updateShape; - ProgressiveCat.prototype = { init: function(view) { @@ -362,13 +361,6 @@ export let ProgressiveCat = (function() { this.drawSources(this.order1Sources, ctx, width, height); this.drawSources(this.order2Sources, ctx, width, height); this.drawSources(this.order3Sources, ctx, width, height); - if (this._shapeIsFunction) { - ctx.restore(); - } - - if (!this.tilesInView) { - return; - } var sources, key, t; for (var k=0; k