Skip to content

Commit 4655290

Browse files
committed
DM-9490: python api enhancements
- extension can be added for any events - two new meta constants for overlay position - absolute position- positionCoord: '10.68479;41.26906;EQ_J2000' - position by row- positionCoordColumns: 'ra_obj;dec_obj;EQ_J2000', - fixed point extension not going into point selection mode if loaded first - fixed coverage so the option keys can be case insensitive - fixed mask not overlaying correctly
1 parent 10f30e4 commit 4655290

23 files changed

+391
-214
lines changed

src/firefly/html/demo/ffapi-coverage-test.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@
7171

7272
firefly.showCoverage('coverageHere',
7373
{
74-
gridOn:true,
74+
gRIdOn:true,
7575
symbol: {aTable: 'X', bTable: 'arrow'},
7676
symbolSize: {aTable: 3, bTable: 12},
7777
color: {aTable: 'blue', bTable: 'yellow'},
7878
// overlayPosition : '149.9;68.8;EQ_J2000',
79-
overlayPosition : '149.08;68.739;EQ_J2000',
79+
OVErlayPosition : '149.08;68.739;EQ_J2000',
8080
});
8181

8282
};

src/firefly/html/demo/ffapi-highlevel-test.html

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
<div>
4141
<a href="javascript:loadMovingTable()">load Moving Table</a>
4242
</div>
43+
<div>
44+
<a href="javascript:loadSimpleImageTable()">load image Table</a>
45+
</div>
46+
<div>
47+
<a href="javascript:loadSimpleM31ImageTable()">load m31 image Table</a>
48+
</div>
4349
<div>
4450
<div id="imageViewHere" style="display: inline-block; width: 550px; height: 550px; margin: 10px;"></div>
4551
<div id="coverageHere" style="display: inline-block; width: 400px; height: 400px; margin: 10px;"></div>
@@ -176,12 +182,35 @@
176182
{ pageSize: 15,
177183
META_INFO: {
178184
datasetInfoConverterId : 'SimpleMoving',
179-
MovingObjCoordColumns: 'ra_obj;dec_obj;EQ_J2000',
185+
//positionCoordColumns: 'ra_obj;dec_obj;EQ_J2000',
186+
positionCoord: '10.68479;41.26906;EQ_J2000',
180187
datasource: 'image_url'
181188
}
182189
});
183190
firefly.getViewer().showTable( req, {removable: true, showUnits: false, showFilters: true});
184191
}
192+
193+
function loadSimpleImageTable() {
194+
var req = firefly.util.table.makeFileRequest('A table of images',
195+
'http://web.ipac.caltech.edu/staff/roby/demo/test-table4.tbl',null,
196+
{ pageSize: 15,
197+
META_INFO: {
198+
datasource: 'FITS'
199+
}
200+
});
201+
firefly.getViewer().showTable( req, {removable: true, showUnits: false, showFilters: true});
202+
}
203+
function loadSimpleM31ImageTable() {
204+
var req = firefly.util.table.makeFileRequest('A table of images',
205+
'http://web.ipac.caltech.edu/staff/roby/demo/test-table-m31.tbl',null,
206+
{ pageSize: 15,
207+
META_INFO: {
208+
positionCoordColumns: 'ra_obj;dec_obj;EQ_J2000',
209+
datasource: 'FITS'
210+
}
211+
});
212+
firefly.getViewer().showTable( req, {removable: true, showUnits: false, showFilters: true});
213+
}
185214
}
186215
</script>
187216

src/firefly/java/edu/caltech/ipac/firefly/visualize/AllPlots.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -733,9 +733,9 @@ public void disableActivePointSelection(boolean onlyDisableWhenUsedExclusively)
733733
//
734734
// }
735735

736-
// public List<Ext.Extension> getExtensionList(String id) {
736+
// public List<Ext.Extension> getPlotUIExtensionList(String id) {
737737
// Ext.ExtensionInterface exI= Ext.makeExtensionInterface();
738-
// JavaScriptObject o= exI.getExtensionList(id);
738+
// JavaScriptObject o= exI.getPlotUIExtensionList(id);
739739
// return Ext.makeIntoList(o);
740740
// if (id==null) id= ALL_MPW;
741741
// int len= exI.getExtLength();
@@ -760,7 +760,7 @@ public Ext.Extension[] getExtensionList(String id) {
760760

761761

762762

763-
// public List<Ext.Extension> getExtensionList(String id) {
763+
// public List<Ext.Extension> getPlotUIExtensionList(String id) {
764764
// if (id==null) id= ALL_MPW;
765765
// Ext.ExtensionInterface exI= Ext.makeExtensionInterface();
766766
// Ext.Extension allExtensions[]= exI.getExtensionListTEST();

src/firefly/java/edu/caltech/ipac/firefly/visualize/MiniPlotWidget.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ private void layout() {
11211121
// lineSelectAdditionActionBar.clear();
11221122
// pointSelectAdditionActionBar.clear();
11231123
// List<PlotCmdExtension> addedList= new ArrayList<PlotCmdExtension>(5);
1124-
// List<PlotCmdExtension> list= AllPlots.getInstance().getExtensionList(plotId);
1124+
// List<PlotCmdExtension> list= AllPlots.getInstance().getPlotUIExtensionList(plotId);
11251125
// if (list!=null) {
11261126
// for(PlotCmdExtension ext : list) {
11271127
// boolean found= false;

src/firefly/js/Firefly.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ import ReactDOM from 'react-dom';
1111
import 'styles/global.css';
1212

1313
import {APP_LOAD} from './core/AppDataCntlr.js';
14-
import {ExtensionJavaInterface } from './gwtinterface/ExtensionJavaInterface.js';
15-
import {ExtensionResult } from './gwtinterface/ExtensionResult.js';
16-
import {PlotCmdExtension } from './visualize/PlotCmdExtension.js';
17-
import {ReactJavaInterface } from './gwtinterface/ReactJavaInterface.jsx';
18-
import {showExampleDialog} from './ui/ExampleDialog.jsx';
1914
import {FireflyViewer} from './templates/fireflyviewer/FireflyViewer.js';
2015
import {LcViewer} from './templates/lightcurve/LcViewer.jsx';
2116
import {initApi} from './api/ApiBuild.js';
@@ -75,17 +70,9 @@ function fireflyInit() {
7570
}
7671

7772
if (!window.firefly) window.firefly= {};
78-
if (!window.firefly.gwt) {
79-
window.firefly.gwt= {};
80-
}
8173

8274
window.firefly.appFlux= appFlux;
83-
window.firefly.gwt.ExtensionJavaInterface= ExtensionJavaInterface;
84-
window.firefly.gwt.ExtensionResult= ExtensionResult;
85-
window.firefly.gwt.PlotCmdExtension= PlotCmdExtension;
86-
window.firefly.gwt.makePlotState= PlotState.makePlotState;
8775
// to call histogram and other react components from GWT
88-
window.firefly.gwt.ReactJavaInterface= ReactJavaInterface;
8976

9077
// a method to get JSON data from external task launcher
9178
window.firefly.getJsonFromTask= function(launcher, task, taskParams) {
@@ -95,7 +82,6 @@ function fireflyInit() {
9582
req.setParam({name : 'taskParams', value : JSON.stringify(taskParams)});
9683
return getJsonData(req);
9784
};
98-
window.firefly.gwt.showExampleDialog= showExampleDialog;
9985
window.firefly.initialized = true;
10086

10187
// start WebSocketClient

src/firefly/js/core/ExternalAccessCntlr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
33
*/
44
import ExternalAccessUtils from './ExternalAccessUtils.js';
5-
import {POINT} from '../visualize/PlotCmdExtension.js';
5+
import {POINT} from './ExternalAccessUtils.js';
66
import {dispatchChangePointSelection} from '../visualize/ImagePlotCntlr.js';
77

88
const EXTENSION_ADD= 'ExternalAccessCntlr/extensionAdd';

src/firefly/js/core/ExternalAccessUtils.js

Lines changed: 113 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,30 @@
22
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
33
*/
44

5-
import {isEmpty} from 'lodash';
5+
import {isEmpty, isUndefined} from 'lodash';
66
import {flux} from '../Firefly.js';
77
import ExternalAccessCntlr from './ExternalAccessCntlr.js';
88
import {reportUserAction} from '../rpc/SearchServicesJson.js';
99
import { parseImagePt, parseWorldPt, parseScreenPt } from '../visualize/Point.js';
1010
import {getWsChannel} from './messaging/WebSocketClient.js';
11+
import {CysConverter} from '../visualize/CsysConverter.js';
12+
import {getTblById, getTblRowAsObj} from '../tables/TableUtil.js';
13+
import {PlotState} from '../visualize/PlotState.js';
14+
import {PlotAttribute} from '../visualize/WebPlot.js';
15+
import {primePlot} from '../visualize/PlotViewUtil.js';
1116

1217
const EMPTY_ARRAY=[];
1318

1419
const doExtensionActivate= function(extension, resultData) {
1520
activate(getRemoteChannel(),extension,resultData);
1621
};
1722

23+
export const AREA_SELECT= 'AREA_SELECT';
24+
export const LINE_SELECT= 'LINE_SELECT';
25+
export const POINT= 'POINT';
26+
export const NONE= 'NONE';
27+
28+
const plotUIExtension= [AREA_SELECT, LINE_SELECT, POINT];
1829

1930

2031
const activate= function(remoteChannel, extension, resultData) {
@@ -42,16 +53,34 @@ export const getRemoteChannel= function() {
4253
return getWsChannel();
4354
};
4455

45-
export const getExtensionList= function(testPlotId) {
56+
export const getPlotUIExtensionList= function(testPlotId) {
57+
var {extensionList}= flux.getState()[ExternalAccessCntlr.EXTERNAL_ACCESS_KEY];
58+
var retList= extensionList.filter((ext) => {
59+
if (plotUIExtension.includes(ext.extType)) {
60+
if (!testPlotId || !ext.plotId || testPlotId === ExternalAccessCntlr.ALL_MPW || ext.plotId === testPlotId) {
61+
return ext;
62+
}
63+
}
64+
});
65+
return isEmpty(retList) ? EMPTY_ARRAY : retList;
66+
};
67+
68+
69+
export const getTblExtensionList= function(testTblId) {
4670
var {extensionList}= flux.getState()[ExternalAccessCntlr.EXTERNAL_ACCESS_KEY];
4771
var retList= extensionList.filter((ext) => {
48-
if (!testPlotId || !ext.plotId || testPlotId === ExternalAccessCntlr.ALL_MPW || ext.plotId === testPlotId) {
49-
return ext;
72+
if (!isUndefined(ext.tbl_id)) {
73+
if (!testTblId || !ext.tbl_id || ext.tbl_id === testTblId) {
74+
return ext;
75+
}
5076
}
5177
});
5278
return isEmpty(retList) ? EMPTY_ARRAY : retList;
5379
};
5480

81+
82+
83+
5584
export const extensionAdd= function(extension) {
5685
flux.process({type: ExternalAccessCntlr.EXTENSION_ADD, payload: {extension}});
5786
};
@@ -71,5 +100,84 @@ export const channelActivate= function(channelId) {
71100

72101

73102
var ExternalAccessUtils= { doExtensionActivate, extensionAdd, extensionRemove, extensionActivate, channelActivate,
74-
getRemoteChannel, getExtensionList };
103+
getRemoteChannel, getPlotUIExtensionList };
75104
export default ExternalAccessUtils;
105+
106+
107+
108+
export function makePlotSelectionExtActivateData(ext, pv, dlAry) {
109+
var plot= primePlot(pv);
110+
var cc= CysConverter.make(plot);
111+
var data= {
112+
id : ext.id,
113+
plotId : pv.plotId,
114+
type: ext.extType,
115+
plotState: PlotState.convertToJSON(plot.plotState)
116+
};
117+
118+
if (plot.attributes.tbl_id) {
119+
const table = getTblById(plot.attributes.tbl_id);
120+
data.table= {
121+
highlightedRow: table.highlightedRow,
122+
row : getTblRowAsObj(table)
123+
};
124+
}
125+
126+
127+
switch (ext.extType) {
128+
case AREA_SELECT:
129+
data= Object.assign(data,getTwoPointSelectObj(plot,cc,PlotAttribute.SELECTION));
130+
break;
131+
case LINE_SELECT:
132+
data= Object.assign(data,getTwoPointSelectObj(plot,cc,PlotAttribute.ACTIVE_DISTANCE));
133+
break;
134+
case POINT:
135+
data= Object.assign(data,getPointSelectObj(plot,cc));
136+
break;
137+
}
138+
139+
return data;
140+
}
141+
142+
function getTwoPointSelectObj(plot,cc,attribute) {
143+
if (!plot.attributes[attribute]) return {};
144+
var {pt0,pt1}=plot.attributes[attribute];
145+
if (!pt0 && !pt1) return {};
146+
147+
var data= {};
148+
var ipt0= cc.getImageCoords(pt0);
149+
var ipt1= cc.getImageCoords(pt1);
150+
if (ipt0 && ipt1) {
151+
data.ipt0= ipt0.toString();
152+
data.ipt1= ipt1.toString();
153+
}
154+
155+
var wpt0= cc.getWorldCoords(pt0);
156+
var wpt1= cc.getWorldCoords(pt1);
157+
if (wpt0 && wpt1) {
158+
data.wpt0= wpt0.toString();
159+
data.wpt1= wpt1.toString();
160+
}
161+
return data;
162+
163+
}
164+
165+
166+
167+
function getPointSelectObj(plot,cc) {
168+
if (!plot.attributes[PlotAttribute.ACTIVE_POINT]) return {};
169+
var {pt}=plot.attributes[PlotAttribute.ACTIVE_POINT];
170+
if (!pt) return {};
171+
172+
var data= {};
173+
var ipt= cc.getImageCoords(pt);
174+
if (ipt) data.ipt= ipt.toString();
175+
176+
var wpt= cc.getWorldCoords(pt);
177+
if (wpt) data.wpt= wpt.toString();
178+
return data;
179+
180+
}
181+
182+
183+

src/firefly/js/core/ReduxFlux.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import createSagaMiddleware from 'redux-saga';
77
import thunkMiddleware from 'redux-thunk';
88
import loggerMiddleware from 'redux-logger';
99
import { createStore, applyMiddleware, combineReducers } from 'redux';
10-
import {dispatchAddSaga} from './MasterSaga.js';
10+
import {masterSaga, dispatchAddSaga} from './MasterSaga.js';
1111
import AppDataCntlr from './AppDataCntlr.js';
1212
import BackgroundCntlr from './background/BackgroundCntlr.js';
1313
import * as LayoutCntlr from './LayoutCntlr.js';
@@ -32,7 +32,6 @@ import DrawLayerFactory from '../visualize/draw/DrawLayerFactory.js';
3232
import DrawLayerCntlr from '../visualize/DrawLayerCntlr.js';
3333
import MultiViewCntlr, {IMAGE_MULTI_VIEW_KEY} from '../visualize/MultiViewCntlr.js';
3434
import ComponentCntlr, {DIALOG_OR_COMPONENT_KEY} from '../core/ComponentCntlr.js';
35-
import {masterSaga} from './MasterSaga.js';
3635

3736

3837

@@ -41,6 +40,7 @@ import {syncCharts} from '../visualize/saga/ChartsSync.js';
4140
import {imagePlotter} from '../visualize/saga/ImagePlotter.js';
4241
import {watchReadout} from '../visualize/saga/MouseReadoutWatch.js';
4342
import {watchForRelatedActions} from '../fieldGroup/FieldGroupCntlr.js';
43+
import {watchExtensionActions} from '../core/messaging/ExternalAccessWatcher.js';
4444

4545

4646

@@ -226,6 +226,7 @@ function startCoreSagas() {
226226
dispatchAddSaga( syncCharts);
227227
dispatchAddSaga( watchReadout);
228228
dispatchAddSaga( watchForRelatedActions);
229+
dispatchAddSaga( watchExtensionActions);
229230
}
230231

231232
function bootstrap() {
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
3+
*/
4+
5+
import {take} from 'redux-saga/effects';
6+
import {isEmpty, isUndefined} from 'lodash';
7+
import {flux} from '../../Firefly.js';
8+
import ExternalAccessCntlr from '../ExternalAccessCntlr.js';
9+
import {makePlotSelectionExtActivateData} from '../ExternalAccessUtils.js';
10+
import {dispatchExtensionActivate} from '../ExternalAccessCntlr.js';
11+
import {getTblRowAsObj, getTblById} from '../../tables/TableUtil.js';
12+
import {DATA_PREFIX, RESULTS_PREFIX, TABLE_HIGHLIGHT} from '../../tables/TablesCntlr.js';
13+
14+
15+
16+
export function* watchExtensionActions() {
17+
18+
while (true) {
19+
20+
const action= yield take();
21+
22+
23+
var {extensionList}= flux.getState()[ExternalAccessCntlr.EXTERNAL_ACCESS_KEY];
24+
if (!isEmpty(extensionList)) {
25+
extensionList
26+
.filter((e) => e.extType === action.type)
27+
.forEach((ext) => dispatchExtensionActivate(ext, makeExtData(ext, action.payload)));
28+
}
29+
30+
}
31+
}
32+
33+
34+
35+
function makeExtData(ext, payload) {
36+
var data= {
37+
id : ext.id,
38+
type: ext.extType
39+
};
40+
if (data.type && data.type.startsWith(DATA_PREFIX) || data.type.startsWith(RESULTS_PREFIX)) {
41+
data.row= getTblRowAsObj( getTblById(payload.tbl_id, payload.highlightedRow));
42+
}
43+
return Object.assign(data,payload);
44+
}

src/firefly/js/data/MetaConst.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export const MetaConst = {
1515
DATA_PRIMARY : 'DataPrimary',
1616
CATALOG_TARGET_COL_NAME : 'CatalogTargetColName',
1717
CATALOG_COORD_COLS : 'CatalogCoordColumns',
18-
MOVING_COORD_COLS : 'MovingObjCoordColumns',
18+
POSITION_COORD_COLS : 'positionCoordColumns',
19+
POSITION_COORD: 'positionCoord',
1920
DATASET_CONVERTER : 'datasetInfoConverterId',
2021
DEFAULT_COLOR : 'DEFAULT_COLOR',
2122
DATA_SOURCE : 'DataSource'

0 commit comments

Comments
 (0)