Skip to content

Commit

Permalink
Firefly-1587: Merge PR #1660 from FIREFLY-1587-overlays
Browse files Browse the repository at this point in the history
Firefly-1587: improving overlays
  • Loading branch information
robyww authored Oct 24, 2024
2 parents eba968d + 46944b6 commit 57c1a73
Show file tree
Hide file tree
Showing 19 changed files with 134 additions and 83 deletions.
18 changes: 15 additions & 3 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


## Version 2024.3
- 2024.3.0 - (Oct 18, 2024), _docker tag_: `latest`, `2024.3`, `2024.3.0`

- 2024.3.1 - (Oct 24, 2024), _docker tag_: `latest`, `2024.3`, `2024.3.1`
- 2024.3.0 - (Oct 18, 2024), _docker tag_: `2024.3.0`

### _Notes_
This Firefly release has a lot of new features, probably among the most new features packed into one release over the past several years.
Expand Down Expand Up @@ -46,7 +46,7 @@ It also includes many, many bug fixes, clean up, and optimization (not all are l
- Fixed: chart is not recognizing short- Firefly-1516 ([PR](https://github.com/Caltech-IPAC/firefly/pull/1595))
- Fixed: popup not closing until second click- Firefly-1514 ([PR](https://github.com/Caltech-IPAC/firefly/pull/1589))
- Fixed: firefly not supporting ellipse in the region save- Firefly-1582 ([PR](https://github.com/Caltech-IPAC/firefly/pull/1654))
- Fixed: import JWST footprint- IRSA-6024 ([PR](https://github.com/Caltech-IPAC/firefly/pull/1643))
- Fixed: import JWST footprint- IRSA-6024 ([PR](https://github.com/Caltech-IPAC/firefly/pull/1660))
- Cleanup: Better recognition of VO table Utype- Firefly-1534 ([PR](https://github.com/Caltech-IPAC/firefly/pull/1636))
- Cleanup: Better tap sizing- Firefly-1562 ([PR](https://github.com/Caltech-IPAC/firefly/pull/1634))
- Cleanup: TAP: ADQL dark mode screen- Firefly-1509 ([PR](https://github.com/Caltech-IPAC/firefly/pull/1590))
Expand All @@ -62,6 +62,18 @@ It also includes many, many bug fixes, clean up, and optimization (not all are l
- nom.tam.fits 1.20- Firefly-1512 ([PR](https://github.com/Caltech-IPAC/firefly/pull/1585))
- other package updates- Firefly-1513 ([PR](https://github.com/Caltech-IPAC/firefly/pull/1587)), Firefly-1503 ([PR](https://github.com/Caltech-IPAC/firefly/pull/1581))

### _Patches 2024.3_

- 2024.3.1
- Bug fix: lock by click not changing images with shift-click and updating correct value ([PR](https://github.com/Caltech-IPAC/firefly/pull/1660))
- Bug fix: data product viewer will use a scrollbar with pngs- Firefly-1589 ([PR](https://github.com/Caltech-IPAC/firefly/pull/1660))
- Bug fix: more drawing layers are now sticky until user remove them- Firefly-1587 ([PR](https://github.com/Caltech-IPAC/firefly/pull/1660))
- Bug fix: coordinate system options for mouse readout and grid are consistent- Firefly-1584 ([PR](https://github.com/Caltech-IPAC/firefly/pull/1660))
- Bug fix: JS API: table in expanded more not switching tabs- - IRSA-6431 ([PR](https://github.com/Caltech-IPAC/firefly/pull/1661))
- Bug fix: Catalogs were not load with certain type of table uploads: Firefly-1583 ([PR](https://github.com/Caltech-IPAC/firefly/pull/1657))
- Bug fix: Upload panel not showing table summary in certain cases: Firefly-1584 ([PR](https://github.com/Caltech-IPAC/firefly/pull/1659))
- When looking for center ra/dec columns in a table, if more than one column has the same UCD, the parser will prefer a floating column over a string

##### _Pull Requests in this release_
- [All Bug Fixes](https://github.com/caltech-ipac/firefly/pulls?q=is%3apr+milestone%3a2024.3+label%3abug)
- [All PRs](https://github.com/caltech-ipac/firefly/pulls?q=is%3apr++milestone%3a2024.3+)
Expand Down
3 changes: 2 additions & 1 deletion src/firefly/js/drawingLayers/FixedPtControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {convertCelestial} from '../visualize/VisUtil.js';
import GpsFixedIcon from '@mui/icons-material/GpsFixed';

export function FixedPtControl({pv, wp, sx = {}}) {
if (!wp) return <div/>;
const llStr = wp.type === Point.W_PT ?
formatLonLatToString(convertCelestial(wp, CoordinateSys.EQ_J2000)) : `${Math.round(wp.x)},${Math.round(wp.y)}`;

Expand All @@ -27,6 +28,6 @@ export function FixedPtControl({pv, wp, sx = {}}) {

FixedPtControl.propTypes = {
pv: PropTypes.object,
wp: PropTypes.object.isRequired,
wp: PropTypes.object,
sx: PropTypes.object
};
46 changes: 24 additions & 22 deletions src/firefly/js/drawingLayers/FootprintTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js';
import {ANGLE_UNIT, OutlineType, getWorldOrImage, findClosestIndex, makeFootprint,
lengthSizeUnit, updateFootprintDrawobjAngle,
updateFootprintTranslate, updateFootprintOutline} from '../visualize/draw/MarkerFootprintObj.js';
import {getCC, cancelTimeoutProcess, initMarkerPos, getPlot, ifUpdateOutline, hasNoProjection,
updateVertexInfo, updateMarkerText, translateForRelocate, getMovement, isGoodPlot} from './MarkerTool.js';
import {
getCC, cancelTimeoutProcess, initMarkerPos, getPlot, ifUpdateOutline, hasNoProjection,
updateVertexInfo, updateMarkerText, translateForRelocate, getMovement, isGoodPlot, MarkerStatus
} from './MarkerTool.js';
import {getFootprintToolUIComponent} from './FootprintToolUI.jsx';
import ShapeDataObj from '../visualize/draw/ShapeDataObj.js';
import {clone} from '../util/WebUtil.js';
Expand Down Expand Up @@ -333,7 +335,8 @@ function creator(initPayload) {
canUserChangeColor: ColorChangeType.DYNAMIC,
canUserDelete: true,
hasPerPlotData: true,
destroyWhenAllDetached: true
destroyWhenAllDetached: false,
destroyWhenAllUserDetached : true
};

const title = initPayload.title ? initPayload.title : getFootprintLayerTitle();
Expand Down Expand Up @@ -361,7 +364,7 @@ function getLayerChanges(drawLayer, action) {
return null;
}

const dd = Object.assign({}, drawLayer.drawData);
const dd = {...drawLayer.drawData};
const {plotIdAry=[]} = drawLayer;
let retV = drawLayer;
let wptObj;
Expand Down Expand Up @@ -403,13 +406,13 @@ function getLayerChanges(drawLayer, action) {
}
break;
case DrawLayerCntlr.ATTACH_LAYER_TO_PLOT:
if (!isEmpty(get(drawLayer, ['drawData', 'data']))) {
get(action.payload, 'plotIdAry', []).forEach((pId) => {
if (isEmpty(get(dd, ['data', pId]))) {
// if (drawLayer?.drawData?.data) {
action.payload?.plotIdAry?.forEach((pId) => {
if (isEmpty(dd?.data?.[pId])) {
retV = attachToNewPlot(retV, pId);
}
});
}
// }
break;

case ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION:
Expand All @@ -433,6 +436,7 @@ function getLayerChanges(drawLayer, action) {
return retV;
}


function getCursor(plotView, screenPt) {
let cursor = '';
const dlAry = dlRoot().drawLayerAry.filter( (dl) => {
Expand Down Expand Up @@ -603,10 +607,11 @@ function createFootprintObjs(action, dl, plotId, wpt, prevRet) {

set(dl.drawData, [DataTypes.DATA, plotId], Object.assign(footprintObj, {actionInfo}));

const dlObj = {drawData: dl.drawData, helpLine: editHelpText};

const dlObj = {drawData: dl.drawData, helpLine: editHelpText, lastDrawData: dl.drawData.data[plotId]};

if (footprintStatus) {
const {exclusiveDef, vertexDef} = updateVertexInfo(footprintObj, plotId, dl, prevRet);
const {exclusiveDef, vertexDef} = updateVertexInfo(footprintObj, plotId, prevRet);

if (exclusiveDef && vertexDef) {
return clone(dlObj, {footprintStatus, vertexDef, exclusiveDef});
Expand Down Expand Up @@ -670,17 +675,15 @@ function resetRotateSide(footprintObj) {
*/
function attachToNewPlot(drawLayer, newPlotId) {
const data = get(drawLayer, ['drawData', 'data'], {});
if (isEmpty(data)) return drawLayer;

const existPlotId = !isEmpty(data) && Object.keys(data).find((pId) => {
return !isEmpty(drawLayer.drawData.data[pId]);
});

if (!existPlotId) return drawLayer;
if (!existPlotId && !drawLayer.lastDrawData) return drawLayer;

const { text, textLoc, renderOptions, actionInfo, translation, angle, angleUnit, regions, isRotatable, pts}
= get(drawLayer, ['drawData', 'data', existPlotId]);
//const newPlotId = plotIdAry.find((pId) => isEmpty(data[pId]));
= drawLayer?.drawData?.data?.[existPlotId] ?? drawLayer.lastDrawData;

const plot = primePlot(visRoot(), newPlotId);
const cc = CsysConverter.make(plot);
Expand Down Expand Up @@ -710,19 +713,18 @@ function attachToNewPlot(drawLayer, newPlotId) {
footprintObj = updateFootprintOutline(footprintObj, cc, true);
}

const aInfo = Object.assign({}, actionInfo, {currentPt: wpt});
set(drawLayer.drawData, [DataTypes.DATA, newPlotId], Object.assign(footprintObj, {
actionInfo: aInfo,
renderOptions, translation
}));
const aInfo = {...actionInfo, currentPt: wpt};

const newDrawData= drawLayer.drawData?.data ? {...drawLayer.drawData} : {data:{}};
newDrawData.data[newPlotId]= {...footprintObj, actionInfo: aInfo, renderOptions, translation };

const dlObj = {drawData: drawLayer.drawData, helpLine: editHelpText};
const dlObj = {drawData: newDrawData, helpLine: editHelpText};

if (aInfo.footprintStatus) {
const {exclusiveDef, vertexDef} = updateVertexInfo(footprintObj, newPlotId, drawLayer, drawLayer);
const {exclusiveDef, vertexDef} = updateVertexInfo(newDrawData.data[newPlotId], newPlotId, drawLayer);

if (exclusiveDef && vertexDef) {
return clone(dlObj, {footprintStatus: aInfo.footprintStatus, vertexDef, exclusiveDef});
return {...dlObj, footprintStatus: aInfo.footprintStatus, vertexDef, exclusiveDef};
}
}
return dlObj;
Expand Down
17 changes: 8 additions & 9 deletions src/firefly/js/drawingLayers/MarkerTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const getMarkerToolUIComponent = (drawLayer,pv) => <MarkerToolUI drawLaye
const ID= 'OVERLAY_MARKER';
const TYPE_ID= 'OVERLAY_MARKER_TYPE';
const factoryDef= makeFactoryDef(TYPE_ID,creator, null, getLayerChanges,null,getMarkerToolUIComponent);
const MarkerStatus = new Enum(['attached', 'select', 'attached_relocate', 'relocate', 'resize']);
export const MarkerStatus = new Enum(['attached', 'select', 'attached_relocate', 'relocate', 'resize']);

export const markerInterval = 3000; // time interval for showing marker with handlers and no handlers
export default {factoryDef, TYPE_ID}; // every draw layer must default export with factoryDef and TYPE_ID
Expand Down Expand Up @@ -511,21 +511,20 @@ function showMarkersByTimer(dispatcher, actionType, plotId, doneStatus, timer, d
* calculate vertex distance for catching the marker
* @param markObj
* @param plotId
* @param dl
* @param dlObj
* @returns {{vertexDef: *, exclusiveDef: *}}
*/
export function updateVertexInfo(markObj, plotId, dl, dlObj) {
var markerStatus = markObj.sType === MarkerType.Marker ? get(markObj, ['actionInfo', 'markerStatus']) :
get(markObj, ['actionInfo', 'footprintStatus']);
var exclusiveDef, vertexDef;
export function updateVertexInfo(markObj, plotId, dlObj) {
const markerStatus = markObj.sType === MarkerType.Marker ?
markObj.actionInfo?.markerStatus : markObj.actionInfo?.footprintStatus;
let exclusiveDef, vertexDef;

if (markerStatus) {
if (markerStatus.key === MarkerStatus.attached.key) {
exclusiveDef = {exclusiveOnDown: true, type: 'anywhere'};
vertexDef = {points: {[plotId]: []}, pointDist: {[plotId]: MARKER_DISTANCE}};
} else {
var cc = CsysConverter.make(primePlot(visRoot(), plotId));
const cc = CsysConverter.make(primePlot(visRoot(), plotId));
const {dist, centerPt} = getVertexDistance(markObj, cc);

exclusiveDef = {exclusiveOnDown: true, type: 'vertexOnly'};
Expand Down Expand Up @@ -634,7 +633,7 @@ function createMarkerObjs(action, dl, plotId, wpt, size, prevRet, unitT) {
var dlObj = {drawData: dl.drawData, helpLine: editHelpText};

if (markerStatus) {
var {exclusiveDef, vertexDef} = updateVertexInfo(markObj, plotId, dl, prevRet);
var {exclusiveDef, vertexDef} = updateVertexInfo(markObj, plotId, prevRet);

if (exclusiveDef && vertexDef) {
return clone(dlObj, {markerStatus, vertexDef, exclusiveDef});
Expand Down Expand Up @@ -818,7 +817,7 @@ function attachToNewPlot(drawLayer, newPlotId) {

const dlObj = {drawData: drawLayer.drawData, helpLine: editHelpText};
if (aInfo.markerStatus) {
const {exclusiveDef, vertexDef} = updateVertexInfo(markerObj, newPlotId, drawLayer, drawLayer);
const {exclusiveDef, vertexDef} = updateVertexInfo(markerObj, newPlotId, drawLayer);

if (exclusiveDef && vertexDef) {
return clone(dlObj, {markerStatus: aInfo.markerStatus, vertexDef, exclusiveDef});
Expand Down
7 changes: 4 additions & 3 deletions src/firefly/js/drawingLayers/WebGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ function creator(params) {
isPointData:false,
useLabels,
canUserChangeColor: ColorChangeType.DYNAMIC,
destroyWhenAllDetached: true
destroyWhenAllDetached: false,
destroyWhenAllUserDetached: true,
};

return DrawLayer.makeDrawLayer( id, TYPE_ID, 'Grid', options , drawingDef, [ImagePlotCntlr.UPDATE_VIEW_SIZE, UPDATE_GRID ]);
Expand Down Expand Up @@ -107,7 +108,7 @@ function getDrawData(dataType, plotId, drawLayer, action, lastDataRet){
let drawData;
switch (action.type){
case ImagePlotCntlr.ANY_REPLOT:
if (drawLayer.drawData.data ) {
if (drawLayer.drawData?.data ) {
if (action.payload.plotIdAry){
const data= clone(drawLayer.drawData.data);
action.payload.plotIdAry.forEach( (plotId) => data[plotId]= null);
Expand All @@ -126,7 +127,7 @@ function getDrawData(dataType, plotId, drawLayer, action, lastDataRet){
break;
case UPDATE_GRID:
case ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION:
if (drawLayer.drawData.data ) {
if (drawLayer.drawData?.data ) {
const data = Object.keys(drawLayer.drawData.data).reduce((d, plotId) => {
d[plotId] = isImage(primePlot(visRoot(), plotId)) ? drawLayer.drawData.data[plotId] : null;
return d;
Expand Down
4 changes: 2 additions & 2 deletions src/firefly/js/drawingLayers/WebGridUI.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {COORDINATE_PREFERENCE} from './WebGrid.js';
export const getUIComponent = (drawLayer,pv) => < WebGridUI drawLayer={drawLayer} pv={pv}/>;

const coordinateOptionArray = [
{label:'Equatorial J2000', value:'eq2000hms'},
{label:'Equatorial J2000 HMS', value:'eq2000hms'},
{label: 'Equatorial J2000 Decimal',value:'eq2000dcm'},
{label: 'Equatorial B1950', value:'eqb1950hms'},
{label: 'Equatorial B1950 HMS', value:'eqb1950hms'},
{label:'Equatorial B1950 Decimal', value:'eqb1950dcm'},
{label:'Galactic', value:'galactic'},
{label: 'Super Galactic', value:'superGalactic'},
Expand Down
2 changes: 1 addition & 1 deletion src/firefly/js/ui/ToolbarButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export const ToolbarButton = forwardRef((props,fRef) => {

ToolbarButton.propTypes= {
icon : oneOfType([element,string]),
text : node,
text : oneOfType([element,string]),
tip : string,
value: string,
title: string,
Expand Down
19 changes: 6 additions & 13 deletions src/firefly/js/ui/tap/SpatialSearch.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {FormLabel, Stack, Typography} from '@mui/joy';
import {Box, FormLabel, Stack, Typography} from '@mui/joy';
import {object, bool, string, func, number, shape} from 'prop-types';
import React, {useContext, useEffect, useState} from 'react';
import {ColsShape, getColValidator} from '../../charts/ui/ColumnOrExpression.jsx';
Expand Down Expand Up @@ -210,11 +210,12 @@ export function SpatialSearch({sx, cols, serviceUrl, serviceLabel, columnsModel,
<ForceFieldGroupValid forceValid={!checkHeaderCtl.isPanelActive()}>

{!canUpload && (searchParams?.uploadInfo || uploadInfo) &&
<div>
<Box>
{<FormLabel>Spatial Type</FormLabel>}
{warningMsg(`Single Shape selected: ${serviceLabel || 'This service'} does not support upload`)}
</div>

<Typography color={'warning'}>
{`Upload option unavailable: ${serviceLabel || 'This service'} does not support upload`}
</Typography>
</Box>
}
{canUpload &&
<RadioGroupInputField {...{
Expand All @@ -240,14 +241,6 @@ export function SpatialSearch({sx, cols, serviceUrl, serviceLabel, columnsModel,
);
}

const warningMsg = (msg) => {
return (
<div style={{display : 'inline-block'}}>
<i>{msg}</i>
</div>
);
};

const OBSCORE_UPLOAD_LAYOUT= 0;
const OBSCORE_SINGLE_LAYOUT= 1;
const NORMAL_UPLOAD_LAYOUT= 2;
Expand Down
1 change: 1 addition & 0 deletions src/firefly/js/visualize/draw/DrawLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ function makeDrawLayer(drawLayerId,
canUserDelete: true,
canUserHide: true,
destroyWhenAllDetached : false, // hint to controller, when all plots have been detached, destroy this layer
destroyWhenAllUserDetached : false, // hint to controller, when all plots have been detached, destroy this layer
helpLine : '',
decimate: false, // enable decimation
canAttachNewPlot: true,
Expand Down
23 changes: 18 additions & 5 deletions src/firefly/js/visualize/saga/MouseReadoutWatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import {callGetFileFlux} from '../../rpc/PlotServicesJson.js';
import {Band} from '../Band.js';
import {MouseState} from '../VisMouseSync.js';
import {CysConverter} from '../CsysConverter.js';
import CsysConverter, {CysConverter} from '../CsysConverter.js';
import {getPixScale, getScreenPixScale, getScreenPixScaleArcSec, isImage, isHiPS, getFluxUnits} from '../WebPlot.js';
import {getPlotTilePixelAngSize} from '../HiPSUtil.js';
import {mouseUpdatePromise, fireMouseReadoutChange} from '../VisMouseSync';
Expand Down Expand Up @@ -45,6 +45,7 @@ const PAUSE_DELAY= 30;
export function* watchReadout() {

let mouseCtx;
let savedWP;
yield call(mouseUpdatePromise);

mouseCtx = yield call(mouseUpdatePromise);
Expand All @@ -53,11 +54,23 @@ export function* watchReadout() {

let getNextWithWithAsync= false;
const lockByClick= isLockByClick(readoutRoot());
const {plotId,worldPt,screenPt,imagePt,mouseState, healpixPixel, norder}= mouseCtx;
let {worldPt,screenPt,imagePt}= mouseCtx;
const {plotId,mouseState, healpixPixel, norder, shiftDown}= mouseCtx;
if (!lockByClick) savedWP= undefined;
if (lockByClick && worldPt && !shiftDown && mouseState===MouseState.CLICK) savedWP= worldPt;

const plotView= getPlotViewById(visRoot(), plotId);
const plot= primePlot(plotView);
const threeColor= plot?.plotState?.threeColor;

if (plot && lockByClick && savedWP && shiftDown && mouseState===MouseState.CLICK) {
worldPt= savedWP;
const cc= CsysConverter.make(plot);
imagePt= cc.getImageCoords(savedWP);
screenPt= cc.getScreenCoords(imagePt);
}


if (isPayloadNeeded(mouseState,lockByClick)) {
if (plot) {
const readoutItems= makeImmediateReadout(plot, worldPt, screenPt, imagePt, threeColor, healpixPixel, norder);
Expand All @@ -70,11 +83,11 @@ export function* watchReadout() {
}

if (getNextWithWithAsync) { // get the next mouse event or the flux
mouseCtx= lockByClick /*|| hasLocalRawData(primePlot(plotView))*/ ?
mouseCtx= lockByClick ?
yield call(processAsyncDataImmediate,plotView, worldPt, screenPt, imagePt, threeColor, healpixPixel, norder) :
yield call(processAsyncDataDelayed,plotView, worldPt, screenPt, imagePt, threeColor, healpixPixel, norder);
}
else { // get the next mouse event
}
else { // get the next mouse event
mouseCtx = yield call(mouseUpdatePromise);
}

Expand Down
1 change: 0 additions & 1 deletion src/firefly/js/visualize/task/PlotImageTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/

import {flatten, isArray, uniqBy} from 'lodash';
import shallowequal from 'shallowequal';
import {getExtName, getExtType} from '../FitsHeaderUtil.js';
import {getCenterPtOfPlot} from '../WebPlotAnalysis';
import {DEFAULT_THUMBNAIL_SIZE, WebPlotRequest, WPConst} from '../WebPlotRequest.js';
Expand Down
2 changes: 1 addition & 1 deletion src/firefly/js/visualize/ui/DrawLayerPanelView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function modifyShape(dl, plotId) {
}

function deleteLayer(dl,plotId) {
dispatchDetachLayerFromPlot(dl.displayGroupId,plotId,true, dl.destroyWhenAllDetached);
dispatchDetachLayerFromPlot(dl.displayGroupId,plotId,true, dl.destroyWhenAllDetached||dl.destroyWhenAllUserDetached);
}

function deleteMaskLayer(opv) {
Expand Down
Loading

0 comments on commit 57c1a73

Please sign in to comment.