Skip to content

Commit 5f37efd

Browse files
committed
Firefly-75: update the HiPS matching on scroll move
- also revamp the dropdown
1 parent 1a3bb63 commit 5f37efd

File tree

6 files changed

+156
-59
lines changed

6 files changed

+156
-59
lines changed

src/firefly/js/visualize/ImagePlotCntlr.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {colorChangeActionCreator, stretchChangeActionCreator, cropActionCreator}
2727
import {wcsMatchActionCreator} from './task/WcsMatchTask.js';
2828
import {autoPlayActionCreator, changePointSelectionActionCreator,
2929
restoreDefaultsActionCreator, deletePlotViewActionCreator} from './task/PlotAdminTask.js';
30+
import {processScrollActionCreator, recenterActionCreator} from './task/PlotChangeTask';
3031

3132
/** enum can be 'COLLAPSE', 'GRID', 'SINGLE' */
3233
export const ExpandType= new Enum(['COLLAPSE', 'GRID', 'SINGLE']);
@@ -271,6 +272,8 @@ function actionCreators() {
271272
[EXPANDED_AUTO_PLAY]: autoPlayActionCreator,
272273
[WCS_MATCH]: wcsMatchActionCreator,
273274
[DELETE_PLOT_VIEW]: deletePlotViewActionCreator,
275+
[RECENTER]: recenterActionCreator,
276+
[PROCESS_SCROLL]: processScrollActionCreator,
274277
};
275278
}
276279

src/firefly/js/visualize/task/PlotChangeTask.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,49 @@
44

55
import {get} from 'lodash';
66
import {logError} from '../../util/WebUtil.js';
7-
import ImagePlotCntlr, {IMAGE_PLOT_KEY} from '../ImagePlotCntlr.js';
7+
import ImagePlotCntlr, {IMAGE_PLOT_KEY, WcsMatchType} from '../ImagePlotCntlr.js';
88
import {primePlot, getPlotViewById, operateOnOthersInOverlayColorGroup, getPlotStateAry} from '../PlotViewUtil.js';
99
import {callCrop, callChangeColor, callRecomputeStretch} from '../../rpc/PlotServicesJson.js';
1010
import WebPlotResult from '../WebPlotResult.js';
1111
import {WebPlot} from '../WebPlot.js';
1212
import {populateFromHeader} from './PlotImageTask';
13+
import {isImage} from '../WebPlot';
14+
import {matchHiPStoPlotView} from './PlotHipsTask';
1315

1416

1517

1618
//=======================================================================
1719
//-------------------- Action Creators ----------------------------------
1820
//=======================================================================
1921

22+
23+
export function recenterActionCreator(rawAction) {
24+
return (dispatcher,getState) => {
25+
dispatcher(rawAction);
26+
locateHiPSIfMatched(getState()[IMAGE_PLOT_KEY], rawAction.payload.plotId);
27+
};
28+
}
29+
30+
31+
export function processScrollActionCreator(rawAction) {
32+
return (dispatcher,getState) => {
33+
dispatcher(rawAction);
34+
locateHiPSIfMatched(getState()[IMAGE_PLOT_KEY], rawAction.payload.plotId);
35+
};
36+
}
37+
38+
/**
39+
* @param {VisRoot} vr
40+
* @param {String} plotId
41+
*/
42+
function locateHiPSIfMatched(vr,plotId) {
43+
const pv = getPlotViewById(vr, plotId);
44+
if (vr.wcsMatchType !== WcsMatchType.Target && vr.wcsMatchType !== WcsMatchType.Standard) return;
45+
if (isImage(primePlot(pv))) matchHiPStoPlotView(vr, pv);
46+
}
47+
48+
49+
2050
/**
2151
* color bar Action creator
2252
* @param rawAction

src/firefly/js/visualize/task/PlotHipsTask.js

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,69 @@
33
*/
44

55
import {get, isEmpty} from 'lodash';
6-
import ImagePlotCntlr, {visRoot, IMAGE_PLOT_KEY,
7-
dispatchChangeCenterOfProjection, dispatchZoom,
6+
import ImagePlotCntlr, {
87
dispatchAttributeChange,
9-
dispatchPlotProgressUpdate, dispatchPlotImage, dispatchPlotHiPS,
10-
dispatchChangeHiPS} from '../ImagePlotCntlr.js';
8+
dispatchChangeCenterOfProjection,
9+
dispatchChangeHiPS,
10+
dispatchPlotHiPS,
11+
dispatchPlotImage,
12+
dispatchPlotProgressUpdate,
13+
dispatchZoom,
14+
IMAGE_PLOT_KEY,
15+
visRoot,
16+
WcsMatchType
17+
} from '../ImagePlotCntlr.js';
1118
import {getArcSecPerPix, getZoomLevelForScale, UserZoomTypes} from '../ZoomUtil.js';
12-
import {WebPlot, PlotAttribute} from '../WebPlot.js';
13-
import {fetchUrl, clone, loadImage} from '../../util/WebUtil.js';
14-
import {primePlot, getPlotViewById} from '../PlotViewUtil.js';
19+
import {PlotAttribute, WebPlot} from '../WebPlot.js';
20+
import {clone, fetchUrl, loadImage} from '../../util/WebUtil.js';
21+
import {
22+
findCurrentCenterPoint,
23+
getCenterOfProjection,
24+
getCorners,
25+
getDrawLayerByType,
26+
getDrawLayersByType,
27+
getFoV,
28+
getPlotViewById,
29+
primePlot,
30+
getPlotViewAry
31+
} from '../PlotViewUtil.js';
1532
import {dispatchAddActionWatcher} from '../../core/MasterSaga.js';
16-
import {getHiPSZoomLevelToFit} from '../HiPSUtil.js';
17-
import {getCenterOfProjection, findCurrentCenterPoint, getCorners,
18-
getDrawLayerByType, getDrawLayersByType, getFoV} from '../PlotViewUtil.js';
19-
import {findAllSkyCachedImage, addAllSkyCachedImage} from '../iv/HiPSTileCache.js';
20-
import {makeHiPSAllSkyUrl, makeHiPSAllSkyUrlFromPlot,
21-
makeHipsUrl, resolveHiPSConstant, getPointMaxSide, getPropertyItem} from '../HiPSUtil.js';
33+
import {
34+
getHiPSZoomLevelToFit,
35+
getPointMaxSide,
36+
getPropertyItem,
37+
makeHiPSAllSkyUrl,
38+
makeHiPSAllSkyUrlFromPlot,
39+
makeHipsUrl,
40+
resolveHiPSConstant
41+
} from '../HiPSUtil.js';
42+
import {addAllSkyCachedImage, findAllSkyCachedImage} from '../iv/HiPSTileCache.js';
2243
import {ZoomType} from '../ZoomType.js';
2344
import {CCUtil} from '../CsysConverter.js';
24-
import {ensureWPR, determineViewerId, getHipsImageConversion,
25-
initBuildInDrawLayers, addDrawLayers} from './PlotImageTask.js';
26-
import {dlRoot, dispatchAttachLayerToPlot,
27-
dispatchCreateDrawLayer, dispatchDetachLayerFromPlot, getDlAry} from '../DrawLayerCntlr.js';
45+
import {
46+
addDrawLayers,
47+
determineViewerId,
48+
ensureWPR,
49+
getHipsImageConversion,
50+
initBuildInDrawLayers
51+
} from './PlotImageTask.js';
52+
import {
53+
dispatchAttachLayerToPlot,
54+
dispatchCreateDrawLayer,
55+
dispatchDetachLayerFromPlot,
56+
dlRoot,
57+
getDlAry
58+
} from '../DrawLayerCntlr.js';
2859
import ImageOutline from '../../drawingLayers/ImageOutline.js';
2960
import Artifact from '../../drawingLayers/Artifact.js';
3061
import {isHiPS, isImage} from '../WebPlot';
3162
import HiPSGrid from '../../drawingLayers/HiPSGrid.js';
3263
import ActiveTarget from '../../drawingLayers/ActiveTarget.js';
3364
import {resolveHiPSIvoURL} from '../HiPSListUtil.js';
34-
import {addNewMocLayer, makeMocTableId, isMOCFitsFromUploadAnalsysis, MOCInfo, UNIQCOL} from '../HiPSMocUtil.js';
65+
import {addNewMocLayer, isMOCFitsFromUploadAnalsysis, makeMocTableId, MOCInfo, UNIQCOL} from '../HiPSMocUtil.js';
3566
import HiPSMOC from '../../drawingLayers/HiPSMOC.js';
3667
import {doUpload} from '../../ui/FileUpload.jsx';
37-
import CoordinateSys from '../CoordSys';
68+
import CoordinateSys from '../CoordSys.js';
3869

3970
const PROXY= true;
4071

@@ -115,7 +146,11 @@ function watchForHiPSViewDim(action, cancelSelf, params) {
115146
if (!plot) return;
116147
const wp= pv.request && pv.request.getWorldPt();
117148

118-
if (!pv.request.getSizeInDeg() && !wp && lockedToOtherHiPS(vr,pv)) { //if nothing enter, match to existing HiPS
149+
if ((vr.wcsMatchType===WcsMatchType.Standard || vr.wcsMatchType===WcsMatchType.Target) &&
150+
isImage(primePlot(getPlotViewById(vr, vr.mpwWcsPrimId)))) {
151+
matchHiPStoPlotView(vr, getPlotViewById(vr, vr.mpwWcsPrimId));
152+
}
153+
else if (!pv.request.getSizeInDeg() && !wp && lockedToOtherHiPS(vr,pv)) { //if nothing enter, match to existing HiPS
119154
const otherPlot= primePlot(getOtherLockedHiPS(vr,pv));
120155
dispatchZoom({ plotId, userZoomType: UserZoomTypes.LEVEL, level:otherPlot.zoomFactor });
121156
const {centerWp}= getPointMaxSide(otherPlot, otherPlot.viewDim);
@@ -481,6 +516,17 @@ function prepFromImageConversion(pv, wpRequest) {
481516
}
482517

483518

519+
/**
520+
*
521+
* @param {VisRoot} visRoot
522+
* @param {PlotView} pv
523+
*/
524+
export function matchHiPStoPlotView(visRoot, pv) {
525+
const hipsViewerIds = getPlotViewAry(visRoot)
526+
.filter((testPv) => isHiPS(primePlot(testPv)))
527+
.map((h) => h.plotId);
528+
matchHiPSToImage(pv, hipsViewerIds);
529+
}
484530

485531

486532

@@ -489,7 +535,7 @@ function prepFromImageConversion(pv, wpRequest) {
489535
* @param {PlotView} pv
490536
* @param {Array.<string>} hipsPVidAry
491537
*/
492-
export function matchHiPSToImage(pv, hipsPVidAry) {
538+
function matchHiPSToImage(pv, hipsPVidAry) {
493539
if (!pv || isEmpty(hipsPVidAry)) return;
494540
const attributes= getCornersAttribute(pv);
495541
const plot= primePlot(pv);
@@ -617,3 +663,4 @@ function getPlotGroupId(imageRequest, hipsRequest) {
617663
if (imageRequest && imageRequest.getPlotGroupId()) return imageRequest.getPlotGroupId();
618664
if (hipsRequest && hipsRequest.getPlotGroupId()) return hipsRequest.getPlotGroupId();
619665
}
666+

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

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,29 @@
44

55
import {get} from 'lodash';
66
import {take} from 'redux-saga/effects';
7-
import ImagePlotCntlr, {WcsMatchType, IMAGE_PLOT_KEY,
8-
dispatchPositionLocking, dispatchZoom, dispatchRotate, dispatchFlip,
9-
dispatchUpdateViewSize, dispatchRecenter, ActionScope} from '../ImagePlotCntlr.js';
10-
import {getPlotViewById, primePlot, applyToOnePvOrAll, findPlotGroup} from '../PlotViewUtil.js';
7+
import ImagePlotCntlr, {
8+
ActionScope,
9+
dispatchFlip,
10+
dispatchPositionLocking,
11+
dispatchRecenter,
12+
dispatchRotate,
13+
dispatchUpdateViewSize,
14+
dispatchZoom,
15+
IMAGE_PLOT_KEY,
16+
WcsMatchType
17+
} from '../ImagePlotCntlr.js';
18+
import {applyToOnePvOrAll, getPlotViewById, primePlot} from '../PlotViewUtil.js';
1119
import {PlotAttribute} from '../WebPlot.js';
12-
import {FullType, isPlotNorth, isEastLeftOfNorth, getRotationAngle, isRotationMatching} from '../VisUtil.js';
13-
import {getEstimatedFullZoomFactor, getArcSecPerPix, getZoomLevelForScale, UserZoomTypes} from '../ZoomUtil.js';
20+
import {FullType, getRotationAngle, isEastLeftOfNorth, isPlotNorth, isRotationMatching} from '../VisUtil.js';
21+
import {getArcSecPerPix, getEstimatedFullZoomFactor, getZoomLevelForScale, UserZoomTypes} from '../ZoomUtil.js';
1422
import {RotateType} from '../PlotState.js';
1523
import {CCUtil} from '../CsysConverter.js';
1624
import {ZoomType} from '../ZoomType.js';
1725
import {makeScreenPt} from '../Point.js';
1826
import {dispatchAddSaga} from '../../core/MasterSaga.js';
19-
import {getCenterOfProjection, getPlotViewAry, hasWCSProjection} from '../PlotViewUtil';
27+
import {getCenterOfProjection, hasWCSProjection} from '../PlotViewUtil';
2028
import {isHiPS, isImage} from '../WebPlot';
21-
import {matchHiPSToImage} from './PlotHipsTask';
22-
import CysConverter from '../CsysConverter';
29+
import {matchHiPStoPlotView} from './PlotHipsTask';
2330
import {dispatchChangeCenterOfProjection, dispatchChangeHiPS} from '../ImagePlotCntlr';
2431

2532

@@ -164,19 +171,6 @@ export function wcsMatchActionCreator(action) {
164171
}
165172

166173

167-
/**
168-
*
169-
* @param {VisRoot} visRoot
170-
* @param {PlotView} pv
171-
*/
172-
export function matchHiPStoPlotView(visRoot, pv) {
173-
const hipsViewerIds= getPlotViewAry(visRoot)
174-
.filter( (testPv) => isHiPS(primePlot(testPv)))
175-
.map( (h) => h.plotId);
176-
matchHiPSToImage(pv, hipsViewerIds);
177-
}
178-
179-
180174

181175

182176

src/firefly/js/visualize/task/ZoomTask.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {isImageViewerSingleLayout, getMultiViewRoot} from '../MultiViewCntlr.js'
1616
import WebPlotResult from '../WebPlotResult.js';
1717
import VisUtil from '../VisUtil.js';
1818
import {doHiPSImageConversionIfNecessary} from './PlotHipsTask.js';
19+
import {matchHiPStoPlotView} from './PlotHipsTask';
1920

2021

2122
const ZOOM_WAIT_MS= 1500; // 1.5 seconds
@@ -71,8 +72,7 @@ export function zoomActionCreator(rawAction) {
7172
zoomLockingEnabled,userZoomType,useDelay, getState);
7273
operateOnOthersInPositionGroup(getState()[IMAGE_PLOT_KEY],pv, matchFunc);
7374
}
74-
visRoot= getState()[IMAGE_PLOT_KEY]; // need a new one after actions
75-
alignWCS(visRoot,pv);
75+
alignWCS(getState,pv);
7676
};
7777

7878
}
@@ -141,14 +141,20 @@ function evaluateZoomType(visRoot, pv, userZoomType, forceDelay, payloadLevel= 1
141141
}
142142

143143

144-
function alignWCS(visRoot, pv) {
144+
function alignWCS(getState, pv) {
145+
let visRoot= getState()[IMAGE_PLOT_KEY];
145146
if (!visRoot.wcsMatchType) return;
146147
if (isImageViewerSingleLayout(getMultiViewRoot(), visRoot, pv.plotId)) {
147148
dispatchUpdateViewSize(pv.plotId);
148149
}
149150
else {
150151
applyToOnePvOrAll(true, visRoot.plotViewAry, pv.plotId, false, (pv) => dispatchUpdateViewSize(pv.plotId) );
151152
}
153+
visRoot= getState()[IMAGE_PLOT_KEY]; // need a new one after actions
154+
pv= getPlotViewById(visRoot, pv.plotId);
155+
if (isImage(primePlot(pv)) && (visRoot.wcsMatchType===WcsMatchType.Target || visRoot.wcsMatchType===WcsMatchType.Standard)) {
156+
matchHiPStoPlotView(visRoot,pv);
157+
}
152158
}
153159

154160

src/firefly/js/visualize/ui/MatchLockDropDown.jsx

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,59 +42,76 @@ export function MatchLockDropDown({visRoot:vr, enabled}) {
4242
const hasTarget= Boolean(p && get(p, ['attributes',PlotAttribute.FIXED_TARGET]));
4343
const pvAry= getPlotViewAry(vr);
4444
const singleSelectedHiPS= isHiPS(p) && pvAry.filter( (pv) => isHiPS(primePlot(pv))).length===1;
45+
const additionalStyle = {paddingLeft: 15};
46+
const titleDiv= {fontSize:'10pt', fontWeight: 'bold', padding: '0 0 3px 0'};
4547

4648
const dropDown= (
4749
<SingleColumnMenu>
48-
<ToolbarButton text='Align by WCS' tip='Align by WCS'
50+
<div style={titleDiv} title='Align only options (will always align but unlock the image and HiPS)'>Align only Options </div>
51+
<ToolbarButton text='by WCS' tip='Align by WCS (no locking)'
4952
enabled={hasWcs && wcsCnt>1 && !singleSelectedHiPS}
5053
horizontal={false} key={'by wcs'}
54+
additionalStyle={additionalStyle}
55+
hasCheckBox={true}
5156
onClick={() => changeMatchType(vr, WcsMatchType.Standard, false)}/>
5257

53-
<ToolbarButton text='Align by Target' tip='Align by Target'
58+
<ToolbarButton text='by Target' tip='Align by Target (no locking)'
5459
enabled={hasTarget && tCnt>1 && !singleSelectedHiPS}
5560
horizontal={false} key={'by target'}
61+
additionalStyle={additionalStyle}
62+
hasCheckBox={true}
5663
onClick={() => changeMatchType(vr, WcsMatchType.Target, false)}/>
5764

58-
<ToolbarButton text='Align by Pixel' tip='Align by Pixel'
65+
<ToolbarButton text='by Pixel' tip='Align by Pixel (no locking)'
5966
enabled={pvAry.length>1 && isImage(p)}
6067
horizontal={false} key={'by pixel'}
68+
additionalStyle={additionalStyle}
69+
hasCheckBox={true}
6170
onClick={() => changeMatchType(vr, WcsMatchType.Pixel, false)}/>
6271

63-
<ToolbarButton text='Align by Pixel at Image Center' tip='Align by Pixel at Image Center'
72+
<ToolbarButton text='by Pixel at Image Center' tip='Align by Pixel at Image Center (no locking)'
6473
enabled={pvAry.length>1 && isImage(p)}
6574
horizontal={false} key={'by pixel/center'}
75+
additionalStyle={additionalStyle}
76+
hasCheckBox={true}
6677
onClick={() => changeMatchType(vr, WcsMatchType.PixelCenter, false)}/>
6778

6879
<DropDownVerticalSeparator useLine={true}/>
69-
<ToolbarButton text='Unlocked' tip='Unlocked' hasCheckBox={true} checkBoxOn={!wcsMatchType}
70-
enabled={true} horizontal={false} key={'unlock'}
71-
onClick={() => changeMatchType(vr, false)}/>
72-
<DropDownVerticalSeparator useLine={true}/>
80+
<div style={titleDiv} title='Align and lock options'>Align and Lock Options</div>
81+
82+
<ToolbarButton text='Unlock' tip='Unlock all image and HiPS' hasCheckBox={true} checkBoxOn={!wcsMatchType}
83+
enabled={true} horizontal={false} key={'unlock'}
84+
additionalStyle={additionalStyle}
85+
onClick={() => changeMatchType(vr, false)}/>
7386

74-
<ToolbarButton text='Align by WCS & Lock' tip='Align by WCS & Lock'
87+
<ToolbarButton text='by WCS' tip='Align by WCS & Lock'
7588
enabled={hasWcs}
7689
horizontal={false} key={'by wcs & Lock'}
7790
hasCheckBox={true} checkBoxOn={wcsMatchType===WcsMatchType.Standard}
91+
additionalStyle={additionalStyle}
7892
onClick={() => changeMatchType(vr, WcsMatchType.Standard, true)}/>
7993

80-
<ToolbarButton text='Align by Target & Lock' tip='Align by Target & Lock'
94+
<ToolbarButton text='by Target' tip='Align by Target & Lock'
8195
enabled={hasTarget}
8296
horizontal={false} key={'by target & Lock'}
8397
hasCheckBox={true} checkBoxOn={wcsMatchType===WcsMatchType.Target}
98+
additionalStyle={additionalStyle}
8499
onClick={() => changeMatchType(vr, WcsMatchType.Target, true)}/>
85100

86-
<ToolbarButton text='Align by Pixel & Lock' tip='Align by Pixel & Lock'
101+
<ToolbarButton text='by Pixel' tip='Align by Pixel & Lock'
87102
enabled={isImage(p)}
88103
hasCheckBox={true}
89104
checkBoxOn={wcsMatchType===WcsMatchType.Pixel}
90105
horizontal={false} key={'by pixel & Lock'}
106+
additionalStyle={additionalStyle}
91107
onClick={() => changeMatchType(vr, WcsMatchType.Pixel, true)}/>
92108

93-
<ToolbarButton text='Align by Pixel at Image Center & Lock' tip='Align by Pixel at Image Center & Lock'
109+
<ToolbarButton text='by Pixel at Image Center' tip='Align by Pixel at Image Center & Lock'
94110
enabled={isImage(p)}
95111
hasCheckBox={true}
96112
checkBoxOn={wcsMatchType===WcsMatchType.PixelCenter}
97113
horizontal={false} key={'by pixel/center & Lock'}
114+
additionalStyle={additionalStyle}
98115
onClick={() => changeMatchType(vr, WcsMatchType.PixelCenter, true)}/>
99116
</SingleColumnMenu>
100117
);

0 commit comments

Comments
 (0)