Skip to content

Commit d85482c

Browse files
authored
Firefly-810: Merge PR #1106 from firefly-810-mask
Firefly-810: Fixed mask not loading correctly when zooming
2 parents ebedc80 + 9f9e4ba commit d85482c

25 files changed

+309
-100
lines changed

docs/release-notes.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
- To Access current (unstable) development - (Version _next_, unreleased) use docker tag: `nightly`
66

77
## Version 2021.2
8+
- 2021.2.4 (July 2021)
9+
- docker tag: `latest`, `release-2021.2`, `release-2021.2.4`
810
- 2021.2.3 (June 2021)
9-
- docker tag: `latest`, `release-2021.2`, `release-2021.2.3`
11+
- docker tag: `release-2021.2.3`
1012
- 2021.2.2 (June 2021)
1113
- docker tag: `release-2021.2.2`
1214
- 2021.2.1 (May 2021)
@@ -48,6 +50,11 @@
4850
- Fixed: further refinement to error handling when retrieving TAP error documents
4951
- Fixed: Simbad name resolution issue ([Firefly-797](https://github.com/Caltech-IPAC/firefly/pull/1103))
5052
- Fixed: Mouse zoom not working correctly ([Firefly-803](https://github.com/Caltech-IPAC/firefly/pull/1103))
53+
- 2021.2.4
54+
- Fixed: Image mask not zooming correctly ([Firefly-810](https://github.com/Caltech-IPAC/firefly/pull/1106))
55+
- Fixed: HiPS select table _i_ link not working ([Firefly-819](https://github.com/Caltech-IPAC/firefly/pull/1106))
56+
- Fixed: bias slider not working in 3 color mode ([PR](https://github.com/Caltech-IPAC/firefly/pull/1106))
57+
- Fixed: boolean table filters not working ([Firefly-805](https://github.com/Caltech-IPAC/firefly/pull/1104))
5158

5259

5360
##### _Pull Request in this release_
@@ -58,7 +65,7 @@
5865

5966
## Version 2021.1
6067
- 2021.1.0 (February 2021)
61-
- docker tag: `latest`, `release-2021.1`, `release-2021.1.0`
68+
- docker tag: `release-2021.1`, `release-2021.1.0`
6269
- original release
6370

6471

src/firefly/java/edu/caltech/ipac/firefly/data/ServerParams.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ public class ServerParams {
169169
public static final String LOGOUT = "CmdLogout";
170170
public static final String TILE_SIZE = "tileSize";
171171
public static final String BACK_TO_URL= "backToUrl";
172+
public static final String MASK_DATA= "maskData";
173+
public static final String MASK_BITS= "maskBits";
172174

173175
//Workspaces
174176
public static final String WS_LIST = "wsList"; // Gets the list of content/files

src/firefly/java/edu/caltech/ipac/firefly/server/rpc/VisServerCommands.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,10 @@ public static class ByteAryCmd extends ServerCommandAccess.HttpCommand {
187187
public void processRequest(HttpServletRequest req, HttpServletResponse res, SrvParam sp) throws Exception {
188188

189189
PlotState state= sp.getState();
190+
boolean mask= sp.getOptionalBoolean(ServerParams.MASK_DATA,false);
191+
int maskBits= sp.getOptionalInt(ServerParams.MASK_BITS,0);
190192
int tileSize = sp.getRequiredInt(ServerParams.TILE_SIZE);
191-
byte [] byte1D= VisServerOps.getByteStretchArray(state,tileSize);
193+
byte [] byte1D= VisServerOps.getByteStretchArray(state,tileSize,mask,maskBits);
192194
res.setContentType("application/octet-stream");
193195

194196
ByteBuffer byteBuf = ByteBuffer.wrap(byte1D);

src/firefly/java/edu/caltech/ipac/firefly/server/visualize/DirectStretchUtils.java

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313
import edu.caltech.ipac.visualize.plot.Histogram;
1414
import edu.caltech.ipac.visualize.plot.ImageData;
1515
import edu.caltech.ipac.visualize.plot.ImageHeader;
16+
import edu.caltech.ipac.visualize.plot.ImageMask;
1617
import edu.caltech.ipac.visualize.plot.RangeValues;
1718
import edu.caltech.ipac.visualize.plot.plotdata.FitsRead;
1819
import edu.caltech.ipac.visualize.plot.plotdata.RGBIntensity;
1920

21+
import java.awt.*;
22+
import java.util.ArrayList;
23+
import java.util.List;
2024
import java.util.concurrent.ExecutorService;
2125
import java.util.concurrent.Executors;
2226
import java.util.concurrent.TimeUnit;
@@ -38,7 +42,8 @@ public class DirectStretchUtils {
3842
return flipped;
3943
}
4044

41-
public static byte [] getStretchData(PlotState state, ActiveFitsReadGroup frGroup, int tileSize) throws InterruptedException {
45+
public static byte [] getStretchData(PlotState state, ActiveFitsReadGroup frGroup, int tileSize, boolean mask, long maskBits)
46+
throws InterruptedException {
4247

4348
FitsRead fr= frGroup.getFitsRead(state.firstBand());
4449
int totWidth= fr.getNaxis1();
@@ -118,6 +123,41 @@ public class DirectStretchUtils {
118123
}
119124
}
120125

126+
}
127+
else if (mask) {
128+
float [] float1d= fr.getRawFloatAry();
129+
final float [] flip1d= flipFloatArray(float1d,totWidth,totHeight);
130+
byte1d= new byte[flip1d.length];
131+
132+
List<ImageMask> masksList= new ArrayList<ImageMask>();
133+
for(int j= 0; (j<31); j++) {
134+
if (((maskBits>>j) & 1) != 0) {
135+
masksList.add(new ImageMask(j,Color.RED));
136+
}
137+
}
138+
ImageMask[] maskAry= masksList.toArray(new ImageMask[0]);
139+
140+
141+
for(int i= 0; i<xPanels; i++) {
142+
for(int j= 0; j<yPanels; j++) {
143+
int width= (i<xPanels-1) ? tileSize : ((totWidth-1) % tileSize + 1);
144+
int height= (j<yPanels-1) ? tileSize : ((totHeight-1) % tileSize + 1);
145+
idx= (i*yPanels) +j;
146+
imageDataAry[idx]= new ImageData( maskAry,
147+
state.getRangeValues(), tileSize*i,tileSize*j, width, height);
148+
ImageData im= imageDataAry[idx];
149+
150+
executor.execute(() -> im.stretchMaskAndSave(flip1d,fr.getNaxis1()));
151+
}
152+
}
153+
executor.shutdown();
154+
normalTermination= executor.awaitTermination(600, TimeUnit.SECONDS);
155+
for (ImageData imageData : imageDataAry) {
156+
byte[] tmpByteAry = imageData.getSavedStandardStretch();
157+
System.arraycopy(tmpByteAry, 0, byte1d, bPos, tmpByteAry.length);
158+
bPos += tmpByteAry.length;
159+
}
160+
121161
}
122162
else {
123163
float [] float1d= fr.getRawFloatAry();

src/firefly/java/edu/caltech/ipac/firefly/server/visualize/VisServerOps.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,12 @@ public static float[] getFloatDataArray(PlotState state, Band band) {
406406

407407

408408

409-
public static byte[] getByteStretchArray(PlotState state, int tileSize) {
409+
public static byte[] getByteStretchArray(PlotState state, int tileSize, boolean mask, long maskBits) {
410410
try {
411411
long start = System.currentTimeMillis();
412412
ActiveCallCtx ctx = CtxControl.prepare(state);
413413
ActiveFitsReadGroup frGroup= ctx.getFitsReadGroup();
414-
byte [] byte1d= DirectStretchUtils.getStretchData(state,frGroup,tileSize);
414+
byte [] byte1d= DirectStretchUtils.getStretchData(state,frGroup,tileSize,mask, maskBits);
415415
long elapse = System.currentTimeMillis() - start;
416416
PlotServUtils.statsLog("byteAry",
417417
"total-MB", (float)byte1d.length / StringUtils.MEG,

src/firefly/java/edu/caltech/ipac/firefly/server/visualize/hips/HiPSMasterList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ private void setupMeta(DataGroup dg, boolean bMulti) {
195195
col.setWidth(4);
196196
col.setFilterable(false);
197197
col.setSortable(false);
198-
col.setLinkInfos(Collections.singletonList(new LinkInfo(null, INFO_ICON_STUB, null, "link to HiPS properties", null, null, null)));
198+
col.setLinkInfos(Collections.singletonList(new LinkInfo(null, INFO_ICON_STUB, "${Properties}", "link to HiPS properties", null, null, null)));
199199
}
200200

201201
private static DataGroup createTableDataFromListEntry(List<HiPSMasterListEntry> hipsMaps) {

src/firefly/java/edu/caltech/ipac/visualize/plot/ImageData.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,24 @@ public byte[] stretch8bit(final float [] float1d, final Header header, final His
266266
return byteAry;
267267
}
268268

269+
public byte[] stretchMask(final float [] float1d, final int naxis1) {
270+
byte [] byteAry= new byte[this.width * this.height];
271+
byte blank_pixel_value = (byte) 255;
272+
int[] pixelhist = new int[256];
273+
274+
ImageStretch.stretchPixelsForMask(x, lastPixel, y, lastLine, naxis1,
275+
blank_pixel_value, float1d, byteAry, pixelhist, imageMasks);
276+
return byteAry;
277+
}
278+
269279
public void stretch8bitAndSave(final float [] float1d, final Header header, final Histogram histogram) {
270280
this.saveStandardStretch = stretch8bit(float1d,header,histogram);
271281
}
272282

283+
public void stretchMaskAndSave(final float [] float1d, final int naxis1) {
284+
this.saveStandardStretch = stretchMask(float1d,naxis1);
285+
}
286+
273287
public byte[] getSavedStandardStretch() { return this.saveStandardStretch; }
274288

275289
public void stretch3ColorAndSave(float [][] float1dAry, ImageHeader [] imHeadAry, Histogram[] histAry,

src/firefly/js/data/ServerParams.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export const ServerParams = {
6565
SCROLL_Y: 'scrollY',
6666
ZOOM_FACTOR: 'zoomFactor',
6767
RANGE_VALUES: 'rangeValues',
68+
MASK_DATA: 'maskData',
69+
MASK_BITS: 'maskBits',
6870

6971
EXT_TYPE: 'extType',
7072
IMAGE: 'image',

src/firefly/js/util/Color.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function toRGBA(/* String */ color, /* Number */ alpha=1) {
4545
}
4646
}
4747

48-
function toRGB(/* String */ color) {
48+
export function toRGB(/* String */ color) {
4949
if (color.startsWith('rgb')) {
5050
const intColor= toRGBA(color);
5151
intColor.length=3;

src/firefly/js/util/WebUtil.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const isOffscreenCanvas= (b) => getGlobalObj().OffscreenCanvas && (b inst
6969

7070
export function createCanvas(width,height) {
7171
const global= getGlobalObj();
72-
const c = global.document ? global.document.createElement('canvas') : new OffscreenCanvas(w,h);
72+
const c = global.document ? global.document.createElement('canvas') : new OffscreenCanvas(width,height);
7373
c.width = width;
7474
c.height = height;
7575
return c;

0 commit comments

Comments
 (0)