Skip to content

Commit 576cada

Browse files
committed
DM-7970: 'dm-7970-lc-image-defaults' into dev
2 parents 3f32880 + c086548 commit 576cada

File tree

7 files changed

+106
-90
lines changed

7 files changed

+106
-90
lines changed

src/firefly/js/templates/lightcurve/LcImageToolbarView.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ export function LcImageToolbarView({activePlotId, viewerId, viewerPlotIds, layou
5151
<div style={{display:'inline-block'}}>
5252
<input style={{margin: 0}}
5353
type='checkbox'
54-
checked={vr.wcsMatchType===WcsMatchType.Standard}
55-
onChange={(ev) => wcsMatchStandard(ev.target.checked, vr.activePlotId) }
54+
checked={vr.wcsMatchType===WcsMatchType.Target}
55+
onChange={(ev) => wcsMatchTarget(ev.target.checked, vr.activePlotId) }
5656
/>
5757
</div>
58-
<div style={tStyle}>WCS Match</div>
58+
<div style={tStyle}>Target Match</div>
5959
</div>
6060
);
6161

@@ -125,6 +125,6 @@ InlineRightToolbarWrapper.propTypes= {
125125
dlAry : PropTypes.array
126126
};
127127

128-
function wcsMatchStandard(doWcsStandard, plotId) {
129-
dispatchWcsMatch({matchType:doWcsStandard?WcsMatchType.Standard:false, plotId});
128+
function wcsMatchTarget(doWcsStandard, plotId) {
129+
dispatchWcsMatch({matchType:doWcsStandard?WcsMatchType.Target:false, plotId});
130130
}

src/firefly/js/templates/lightcurve/LcManager.js

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {TBL_RESULTS_ADDED, TABLE_LOADED, TBL_RESULTS_ACTIVE, TABLE_HIGHLIGHT} fr
1010
import {getCellValue, getTblById, makeTblRequest} from '../../tables/TableUtil.js';
1111
import {updateSet} from '../../util/WebUtil.js';
1212
import {dispatchPlotImage, visRoot, dispatchDeletePlotView,
13-
dispatchChangeActivePlotView} from '../../visualize/ImagePlotCntlr.js';
13+
dispatchChangeActivePlotView,
14+
WcsMatchType, dispatchWcsMatch} from '../../visualize/ImagePlotCntlr.js';
1415
import {getPlotViewById} from '../../visualize/PlotViewUtil.js';
1516
import {getMultiViewRoot, dispatchReplaceViewerItems, getViewer} from '../../visualize/MultiViewCntlr.js';
1617
import {WebPlotRequest,TitleOptions} from '../../visualize/WebPlotRequest.js';
@@ -20,6 +21,8 @@ import {ServerRequest} from '../../data/ServerRequest.js';
2021
import {CHANGE_VIEWER_LAYOUT} from '../../visualize/MultiViewCntlr.js';
2122
import {LcPFOptionsPanel, grpkey} from './LcPhaseFoldingPanel.jsx';
2223
import FieldGroupUtils, {revalidateFields} from '../../fieldGroup/FieldGroupUtils';
24+
import {makeWorldPt} from '../../visualize/Point.js';
25+
import {CoordinateSys} from '../../visualize/CoordSys.js';
2326

2427
export const LC = {
2528
RAW_TABLE: 'raw_table',
@@ -173,14 +176,7 @@ function getWebPlotRequest(tableModel, hlrow) {
173176
sr.setParam('in_dec',`${dec}`);
174177

175178
const reqParams = WebPlotRequest.makeProcessorRequest(sr, 'wise');
176-
reqParams.setTitle('WISE-'+ frameId);
177-
reqParams.setGroupLocked(true);
178-
reqParams.setPlotGroupId('LightCurveGroup');
179-
reqParams.setPreferenceColorKey('light-curve-color-pref');
180-
return reqParams;
181-
182-
183-
179+
return addCommonReqParams(reqParams, frameId, makeWorldPt(ra,dec,CoordinateSys.EQ_J2000));
184180
}
185181

186182
function getWebPlotRequestViaUrl(tableModel, hlrow, cutoutSize) {
@@ -204,15 +200,19 @@ function getWebPlotRequestViaUrl(tableModel, hlrow, cutoutSize) {
204200
const url = `${serverinfo}${scangrp}/${scan_id}/${frame_num}/${scan_id}${frame_num}-w1-int-1b.fits${centerandsize}`;
205201
const plot_desc = `WISE-${frameId}`;
206202
const reqParams = WebPlotRequest.makeURLPlotRequest(url, plot_desc);
207-
reqParams.setTitle('WISE-'+ frameId + (cutoutSize ? ` size: ${cutoutSize}(deg)` : ''));
208-
reqParams.setTitleOptions(TitleOptions.NONE);
209-
reqParams.setGroupLocked(true);
210-
reqParams.setPlotGroupId('LightCurveGroup');
211-
reqParams.setPreferenceColorKey('light-curve-color-pref');
212-
return reqParams;
213-
214-
203+
const title= 'WISE-'+ frameId + (cutoutSize ? ` size: ${cutoutSize}(deg)` : '');
204+
return addCommonReqParams(reqParams, title, makeWorldPt(ra,dec,CoordinateSys.EQ_J2000));
205+
}
215206

207+
function addCommonReqParams(inWpr,title,wp) {
208+
const retWpr= inWpr.makeCopy();
209+
retWpr.setTitle(title);
210+
retWpr.setTitleOptions(TitleOptions.NONE);
211+
retWpr.setGroupLocked(true);
212+
retWpr.setPlotGroupId('LightCurveGroup');
213+
retWpr.setPreferenceColorKey('light-curve-color-pref');
214+
retWpr.setOverlayPosition(wp);
215+
return retWpr;
216216
}
217217

218218
export function setupImages(tbl_id) {
@@ -222,6 +222,7 @@ export function setupImages(tbl_id) {
222222
const tableModel = getTblById(tbl_id);
223223
if (!tableModel || isNil(tableModel.highlightedRow)) return;
224224
var vr= visRoot();
225+
const hasPlots= vr.plotViewAry.length>0;
225226
const newPlotIdAry= makePlotIds(tableModel.highlightedRow, tableModel.totalRows,count);
226227
const maxPlotIdAry= makePlotIds(tableModel.highlightedRow, tableModel.totalRows,LC.MAX_IMAGE_CNT);
227228

@@ -240,7 +241,14 @@ export function setupImages(tbl_id) {
240241

241242

242243
dispatchReplaceViewerItems(LC.IMG_VIEWER_ID, newPlotIdAry);
243-
dispatchChangeActivePlotView(plotIdRoot+tableModel.highlightedRow);
244+
const newActivePlotId= plotIdRoot+tableModel.highlightedRow;
245+
dispatchChangeActivePlotView(newActivePlotId);
246+
247+
248+
vr= visRoot();
249+
if (!vr.wcsMatchType && !hasPlots) {
250+
dispatchWcsMatch({matchType:WcsMatchType.Target, plotId:newActivePlotId});
251+
}
244252

245253
vr= visRoot();
246254

src/firefly/js/visualize/PlotViewUtil.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,20 @@ export function expandedPlotViewAry(ref,activePlotId=null) {
9090
* @param visRoot - root of the visualization object in store
9191
* @param pvOrId this parameter will take the plotId string or a plotView object
9292
* @param onlyIfGroupLocked
93+
* @param hasPlots
9394
* @returns {*}
9495
*/
95-
export function getPlotViewIdListInGroup(visRoot,pvOrId,onlyIfGroupLocked=true) {
96+
export function getPlotViewIdListInGroup(visRoot,pvOrId,onlyIfGroupLocked=true, hasPlots=false) {
9697
if (!pvOrId) return [];
9798
var pv= (typeof pvOrId ==='string') ? getPlotViewById(visRoot,pvOrId) : pvOrId;
9899
var gid= pv.plotGroupId;
99100
var group= getPlotGroupById(visRoot,gid);
100101
var locked= hasGroupLock(pv,group);
101102
if (!locked && onlyIfGroupLocked) return [pv.plotId];
102-
return visRoot.plotViewAry.filter( (pv) => pv.plotGroupId===gid).map( (pv) => pv.plotId);
103+
const idList= visRoot.plotViewAry.filter( (pv) => pv.plotGroupId===gid).map( (pv) => pv.plotId);
104+
if (!hasPlots) return idList;
105+
106+
return idList.filter( (id) => get(getPlotViewById(visRoot,id),'plots.length') );
103107
}
104108

105109

src/firefly/js/visualize/Point.js

Lines changed: 39 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,6 @@ var Point = { SPT, IM_PT, IM_WS_PT, VP_PT, PROJ_PT, W_PT, OFFSET_PT};
6161
* @global
6262
*/
6363

64-
var ptTypes= Object.values(Point);
65-
66-
//var makePt = function (x, y) {
67-
// var retval= {};
68-
// retval.getX = function () { return x; };
69-
// retval.getY = function () { return y; };
70-
// retval.toString= function() {
71-
// return x+";"+y;
72-
// };
73-
// return retval;
74-
//};
7564

7665

7766
export class SimplePt {
@@ -192,8 +181,8 @@ function stringAryToWorldPt(wpParts) {
192181

193182
/**
194183
* @summary A point on the sky with a coordinate system
195-
* @param {number} lon - longitude in degrees
196-
* @param {number} lat - latitude in degrees
184+
* @param {number|string} lon - longitude in degrees, strings are converted to numbers
185+
* @param {number|string} lat - latitude in degrees, strings are converted to numbers
197186
* @param {CoordinateSys} coordSys - The coordinate system of this worldPt
198187
*
199188
* @param {String} [objName] - object name used to create this worldPt
@@ -206,16 +195,14 @@ function stringAryToWorldPt(wpParts) {
206195
* @global
207196
*/
208197
export const makeWorldPt= function (lon,lat,coordSys,objName,resolver) {
209-
if (typeof lon === 'string') lon= Number(lon);
210-
if (typeof lat === 'string') lat= Number(lat);
211-
return new WorldPt(lon,lat,coordSys,objName,resolver) ;
198+
return new WorldPt(Number(lon),Number(lat),coordSys,objName,resolver) ;
212199
};
213200

214201

215202
/**
216203
* @summary A point in the image file
217-
* @param {number} x - the x
218-
* @param {number} y - the y
204+
* @param {number|string} x - the x, string is converted to number
205+
* @param {number|string} y - the y, string is converted to number
219206
*
220207
* @return {ImagePt}
221208
*
@@ -224,31 +211,25 @@ export const makeWorldPt= function (lon,lat,coordSys,objName,resolver) {
224211
* @public
225212
* @global
226213
*/
227-
export const makeImagePt= function(x,y) {
228-
if (typeof x === 'string') x= Number(x);
229-
if (typeof y === 'string') y= Number(y);
230-
return Object.assign(new SimplePt(x,y), {type:IM_PT});
231-
};
214+
export const makeImagePt= (x,y) => Object.assign(new SimplePt(Number(x),Number(y)), {type:IM_PT});
215+
232216

233217
/**
234218
*
235-
* @param x
236-
* @param y
219+
* @param {number|string} x - the x, string is converted to number
220+
* @param {number|string} y - the y, string is converted to number
237221
* @memberof firefly.util.image
238222
* @return {Pt}
239223
*/
240-
export const makeImageWorkSpacePt= function(x,y) {
241-
if (typeof x === 'string') x= Number(x);
242-
if (typeof y === 'string') y= Number(y);
243-
return Object.assign(new SimplePt(x,y), {type:IM_WS_PT});
244-
};
224+
export const makeImageWorkSpacePt= (x,y) => Object.assign(new SimplePt(Number(x),Number(y)), {type:IM_WS_PT});
225+
245226

246227

247228

248229
/**
249230
* @summary A point of the display image
250-
* @param {number} x - the x
251-
* @param {number} y - the y
231+
* @param {number|string} x - the x, string is converted to number
232+
* @param {number|string} y - the y, string is converted to number
252233
*
253234
* @return {ScreenPt}
254235
*
@@ -257,27 +238,31 @@ export const makeImageWorkSpacePt= function(x,y) {
257238
* @public
258239
* @global
259240
*/
260-
export const makeScreenPt= function(x,y) {
261-
if (typeof x === 'string') x= Number(x);
262-
if (typeof y === 'string') y= Number(y);
263-
return Object.assign(new SimplePt(x,y), {type:SPT});
264-
};
265-
export const makeViewPortPt= function(x,y) {
266-
if (typeof x === 'string') x= Number(x);
267-
if (typeof y === 'string') y= Number(y);
268-
return Object.assign(new SimplePt(x,y), {type:VP_PT});
269-
};
270-
export const makeProjectionPt= function(x,y) {
271-
if (typeof x === 'string') x= Number(x);
272-
if (typeof y === 'string') y= Number(y);
273-
return Object.assign(new SimplePt(x,y), {type:PROJ_PT});
274-
};
275-
export const makeOffsetPt= function(x,y) {
276-
if (typeof x === 'string') x= Number(x);
277-
if (typeof y === 'string') y= Number(y);
278-
return Object.assign(new SimplePt(x,y), {type:OFFSET_PT});
279-
};
241+
export const makeScreenPt= (x,y) => Object.assign(new SimplePt(Number(x),Number(y)), {type:SPT});
242+
243+
export const makeViewPortPt= (x,y) => Object.assign(new SimplePt(Number(x),Number(y)), {type:VP_PT});
244+
245+
export const makeProjectionPt= (x,y) => Object.assign(new SimplePt(Number(x),Number(y)), {type:PROJ_PT});
280246

247+
export const makeOffsetPt= (x,y) => Object.assign(new SimplePt(Number(x),Number(y)), {type:OFFSET_PT});
248+
249+
250+
/**
251+
* @summary Test if two points are equals. They must be the same coordinate system and have the same values to be
252+
* equal. Two points that are null or undefined are also considered equal.
253+
* If both points are WorldPt and are equal in values and coordindate system but have a
254+
* different resolver and object names, * they are still considered equal.
255+
*
256+
* @param {Point} p1 - the first point
257+
* @param {Point} p2 - the second point
258+
*
259+
* @return true if equals
260+
*
261+
* @function pointEquals
262+
* @memberof firefly.util.image
263+
* @public
264+
* @global
265+
*/
281266
export const pointEquals= function(p1,p2) {
282267
if (isNil(p1) && isNil(p2)) return true;
283268
else if (isNil(p1) || isNil(p2)) return false;
@@ -327,6 +312,8 @@ export const parseWorldPt = function (serializedWP) {
327312
return stringAryToWorldPt(sAry);
328313
};
329314

315+
const ptTypes= Object.values(Point);
316+
330317
export const isValidPoint= (testPt) => (testPt && testPt.type && ptTypes.includes(testPt.type));
331318

332319
export default Point;

src/firefly/js/visualize/reducer/HandlePlotCreation.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,23 +147,35 @@ function updateForWcsMatching(visRoot, pv, mpwWcsPrimId) {
147147
const plot= primePlot(pv);
148148
if (!plot || !wcsMatchType ) return pv;
149149

150-
if (mpwWcsPrimId!==pv.plotId) {
151-
const offPt= findWCSMatchOffset(visRoot, mpwWcsPrimId, primePlot(pv));
152-
const masterPv=getPlotViewById(visRoot,mpwWcsPrimId);
153-
if (masterPv) {
154-
pv= updatePlotViewScrollXY(pv, makeScreenPt(masterPv.scrollX-offPt.x, masterPv.scrollY-offPt.y), false);
150+
if (wcsMatchType===WcsMatchType.Standard) {
151+
if (mpwWcsPrimId!==pv.plotId) {
152+
const offPt= findWCSMatchOffset(visRoot, mpwWcsPrimId, primePlot(pv));
153+
const masterPv=getPlotViewById(visRoot,mpwWcsPrimId);
154+
if (masterPv) {
155+
pv= updatePlotViewScrollXY(pv, makeScreenPt(masterPv.scrollX-offPt.x, masterPv.scrollY-offPt.y), false);
156+
}
155157
}
156158
}
157-
else if (wcsMatchType===WcsMatchType.Target && getPlotViewIdListInGroup(visRoot,pv.plotId).length<2) {
158-
const ft= plot.attributes[PlotAttribute.FIXED_TARGET];
159-
if (ft) {
160-
const centerImagePt = CCUtil.getImageCoords(plot, ft);
161-
pv= updatePlotViewScrollXY(pv, PlotView.findScrollPtForImagePt(pv, centerImagePt, false));
159+
else if (wcsMatchType===WcsMatchType.Target) {
160+
if (getPlotViewIdListInGroup(visRoot,pv.plotId,true,true).length<2) {
161+
const ft= plot.attributes[PlotAttribute.FIXED_TARGET];
162+
if (ft) {
163+
const centerImagePt = CCUtil.getImageCoords(plot, ft);
164+
pv= updatePlotViewScrollXY(pv, PlotView.findScrollPtForImagePt(pv, centerImagePt, false));
165+
}
166+
}
167+
else {
168+
const offPt= findWCSMatchOffset(visRoot, mpwWcsPrimId, primePlot(pv));
169+
const masterPv=getPlotViewById(visRoot,mpwWcsPrimId);
170+
if (masterPv) {
171+
pv= updatePlotViewScrollXY(pv, makeScreenPt(masterPv.scrollX-offPt.x, masterPv.scrollY-offPt.y), false);
172+
}
162173
}
163174
}
164175
return pv;
165176
}
166177

178+
167179
function newOverlayPrep(state, action) {
168180
const {plotId, imageOverlayId, imageNumber, maskValue, maskNumber, color, title, drawingDef}= action.payload;
169181

src/firefly/js/visualize/reducer/PlotView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ function getNewAttributes(plot) {
472472

473473
if (worldPt) {
474474
const cc= CysConverter.make(plot);
475-
if (cc.pointInPlot(worldPt)) {
475+
if (cc.pointInPlot(worldPt) || req.getOverlayPosition()) {
476476
attributes[PlotAttribute.FIXED_TARGET]= worldPt;
477477
if (circle) attributes[PlotAttribute.REQUESTED_SIZE]= circle.radius; // says radius but really size
478478
}

src/firefly/js/visualize/task/WcsMatchTask.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,21 @@ export function wcsMatchActionCreator(action) {
3030

3131
var group= findPlotGroup(masterPv.plotGroupId, visRoot.plotGroupAry);
3232

33-
if (!matchType || matchType.Off || !width || !height) {
33+
34+
if (!matchType || !width || !height) {
3435
dispatcher({
3536
type: ImagePlotCntlr.WCS_MATCH,
36-
payload: {wcsMatchCenterWP:null,wcsMatchType:false,mpwWcsPrimId:null}
37+
payload: {wcsMatchCenterWP:null,wcsMatchType:matchType,mpwWcsPrimId:plotId}
3738
});
3839
applyToOnePvOrGroup(visRoot.plotViewAry, masterPv.plotId, group,
3940
(pv) => dispatchUpdateViewSize(pv.plotId));
4041
return;
4142
}
43+
4244
const wcsMatchCenterWP= findWcsMatchPoint(masterPv, plotId, matchType);
4345

46+
47+
4448
dispatcher({
4549
type: ImagePlotCntlr.WCS_MATCH,
4650
payload: {wcsMatchCenterWP,wcsMatchType:matchType,mpwWcsPrimId:masterPv.plotId}
@@ -174,6 +178,7 @@ function isRotationMatching(p1, p2) {
174178
*/
175179
function findWcsMatchPoint(pv, plotId, matchType) {
176180
const p= primePlot(pv);
181+
if (!p) return null;
177182
switch (matchType) {
178183
case WcsMatchType.Standard:
179184
return CCUtil.getWorldCoords(p, makeScreenPt(p.screenSize.width/2,p.screenSize.height/2));

0 commit comments

Comments
 (0)