Skip to content

DM-9490: python api enhancements #309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/firefly/html/demo/ffapi-coverage-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@

firefly.showCoverage('coverageHere',
{
gridOn:true,
gRIdOn:true,
symbol: {aTable: 'X', bTable: 'arrow'},
symbolSize: {aTable: 3, bTable: 12},
color: {aTable: 'blue', bTable: 'yellow'},
// overlayPosition : '149.9;68.8;EQ_J2000',
overlayPosition : '149.08;68.739;EQ_J2000',
OVErlayPosition : '149.08;68.739;EQ_J2000',
});

};
Expand Down
31 changes: 30 additions & 1 deletion src/firefly/html/demo/ffapi-highlevel-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
<div>
<a href="javascript:loadMovingTable()">load Moving Table</a>
</div>
<div>
<a href="javascript:loadSimpleImageTable()">load image Table</a>
</div>
<div>
<a href="javascript:loadSimpleM31ImageTable()">load m31 image Table</a>
</div>
<div>
<div id="imageViewHere" style="display: inline-block; width: 550px; height: 550px; margin: 10px;"></div>
<div id="coverageHere" style="display: inline-block; width: 400px; height: 400px; margin: 10px;"></div>
Expand Down Expand Up @@ -176,12 +182,35 @@
{ pageSize: 15,
META_INFO: {
datasetInfoConverterId : 'SimpleMoving',
MovingObjCoordColumns: 'ra_obj;dec_obj;EQ_J2000',
//positionCoordColumns: 'ra_obj;dec_obj;EQ_J2000',
positionCoord: '10.68479;41.26906;EQ_J2000',
datasource: 'image_url'
}
});
firefly.getViewer().showTable( req, {removable: true, showUnits: false, showFilters: true});
}

function loadSimpleImageTable() {
var req = firefly.util.table.makeFileRequest('A table of images',
'http://web.ipac.caltech.edu/staff/roby/demo/test-table4.tbl',null,
{ pageSize: 15,
META_INFO: {
datasource: 'FITS'
}
});
firefly.getViewer().showTable( req, {removable: true, showUnits: false, showFilters: true});
}
function loadSimpleM31ImageTable() {
var req = firefly.util.table.makeFileRequest('A table of images',
'http://web.ipac.caltech.edu/staff/roby/demo/test-table-m31.tbl',null,
{ pageSize: 15,
META_INFO: {
positionCoordColumns: 'ra_obj;dec_obj;EQ_J2000',
datasource: 'FITS'
}
});
firefly.getViewer().showTable( req, {removable: true, showUnits: false, showFilters: true});
}
}
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,9 +733,9 @@ public void disableActivePointSelection(boolean onlyDisableWhenUsedExclusively)
//
// }

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



// public List<Ext.Extension> getExtensionList(String id) {
// public List<Ext.Extension> getPlotUIExtensionList(String id) {
// if (id==null) id= ALL_MPW;
// Ext.ExtensionInterface exI= Ext.makeExtensionInterface();
// Ext.Extension allExtensions[]= exI.getExtensionListTEST();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ private void layout() {
// lineSelectAdditionActionBar.clear();
// pointSelectAdditionActionBar.clear();
// List<PlotCmdExtension> addedList= new ArrayList<PlotCmdExtension>(5);
// List<PlotCmdExtension> list= AllPlots.getInstance().getExtensionList(plotId);
// List<PlotCmdExtension> list= AllPlots.getInstance().getPlotUIExtensionList(plotId);
// if (list!=null) {
// for(PlotCmdExtension ext : list) {
// boolean found= false;
Expand Down
14 changes: 0 additions & 14 deletions src/firefly/js/Firefly.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ import ReactDOM from 'react-dom';
import 'styles/global.css';

import {APP_LOAD} from './core/AppDataCntlr.js';
import {ExtensionJavaInterface } from './gwtinterface/ExtensionJavaInterface.js';
import {ExtensionResult } from './gwtinterface/ExtensionResult.js';
import {PlotCmdExtension } from './visualize/PlotCmdExtension.js';
import {ReactJavaInterface } from './gwtinterface/ReactJavaInterface.jsx';
import {showExampleDialog} from './ui/ExampleDialog.jsx';
import {FireflyViewer} from './templates/fireflyviewer/FireflyViewer.js';
import {LcViewer} from './templates/lightcurve/LcViewer.jsx';
import {initApi} from './api/ApiBuild.js';
Expand Down Expand Up @@ -75,17 +70,9 @@ function fireflyInit() {
}

if (!window.firefly) window.firefly= {};
if (!window.firefly.gwt) {
window.firefly.gwt= {};
}

window.firefly.appFlux= appFlux;
window.firefly.gwt.ExtensionJavaInterface= ExtensionJavaInterface;
window.firefly.gwt.ExtensionResult= ExtensionResult;
window.firefly.gwt.PlotCmdExtension= PlotCmdExtension;
window.firefly.gwt.makePlotState= PlotState.makePlotState;
// to call histogram and other react components from GWT
window.firefly.gwt.ReactJavaInterface= ReactJavaInterface;

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

// start WebSocketClient
Expand Down
2 changes: 1 addition & 1 deletion src/firefly/js/core/ExternalAccessCntlr.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
*/
import ExternalAccessUtils from './ExternalAccessUtils.js';
import {POINT} from '../visualize/PlotCmdExtension.js';
import {POINT} from './ExternalAccessUtils.js';
import {dispatchChangePointSelection} from '../visualize/ImagePlotCntlr.js';

const EXTENSION_ADD= 'ExternalAccessCntlr/extensionAdd';
Expand Down
118 changes: 113 additions & 5 deletions src/firefly/js/core/ExternalAccessUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,30 @@
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
*/

import {isEmpty} from 'lodash';
import {isEmpty, isUndefined} from 'lodash';
import {flux} from '../Firefly.js';
import ExternalAccessCntlr from './ExternalAccessCntlr.js';
import {reportUserAction} from '../rpc/SearchServicesJson.js';
import { parseImagePt, parseWorldPt, parseScreenPt } from '../visualize/Point.js';
import {getWsChannel} from './messaging/WebSocketClient.js';
import {CysConverter} from '../visualize/CsysConverter.js';
import {getTblById, getTblRowAsObj} from '../tables/TableUtil.js';
import {PlotState} from '../visualize/PlotState.js';
import {PlotAttribute} from '../visualize/WebPlot.js';
import {primePlot} from '../visualize/PlotViewUtil.js';

const EMPTY_ARRAY=[];

const doExtensionActivate= function(extension, resultData) {
activate(getRemoteChannel(),extension,resultData);
};

export const AREA_SELECT= 'AREA_SELECT';
export const LINE_SELECT= 'LINE_SELECT';
export const POINT= 'POINT';
export const NONE= 'NONE';

const plotUIExtension= [AREA_SELECT, LINE_SELECT, POINT];


const activate= function(remoteChannel, extension, resultData) {
Expand Down Expand Up @@ -42,16 +53,34 @@ export const getRemoteChannel= function() {
return getWsChannel();
};

export const getExtensionList= function(testPlotId) {
export const getPlotUIExtensionList= function(testPlotId) {
var {extensionList}= flux.getState()[ExternalAccessCntlr.EXTERNAL_ACCESS_KEY];
var retList= extensionList.filter((ext) => {
if (plotUIExtension.includes(ext.extType)) {
if (!testPlotId || !ext.plotId || testPlotId === ExternalAccessCntlr.ALL_MPW || ext.plotId === testPlotId) {
return ext;
}
}
});
return isEmpty(retList) ? EMPTY_ARRAY : retList;
};


export const getTblExtensionList= function(testTblId) {
var {extensionList}= flux.getState()[ExternalAccessCntlr.EXTERNAL_ACCESS_KEY];
var retList= extensionList.filter((ext) => {
if (!testPlotId || !ext.plotId || testPlotId === ExternalAccessCntlr.ALL_MPW || ext.plotId === testPlotId) {
return ext;
if (!isUndefined(ext.tbl_id)) {
if (!testTblId || !ext.tbl_id || ext.tbl_id === testTblId) {
return ext;
}
}
});
return isEmpty(retList) ? EMPTY_ARRAY : retList;
};




export const extensionAdd= function(extension) {
flux.process({type: ExternalAccessCntlr.EXTENSION_ADD, payload: {extension}});
};
Expand All @@ -71,5 +100,84 @@ export const channelActivate= function(channelId) {


var ExternalAccessUtils= { doExtensionActivate, extensionAdd, extensionRemove, extensionActivate, channelActivate,
getRemoteChannel, getExtensionList };
getRemoteChannel, getPlotUIExtensionList };
export default ExternalAccessUtils;



export function makePlotSelectionExtActivateData(ext, pv, dlAry) {
var plot= primePlot(pv);
var cc= CysConverter.make(plot);
var data= {
id : ext.id,
plotId : pv.plotId,
type: ext.extType,
plotState: PlotState.convertToJSON(plot.plotState)
};

if (plot.attributes.tbl_id) {
const table = getTblById(plot.attributes.tbl_id);
data.table= {
highlightedRow: table.highlightedRow,
row : getTblRowAsObj(table)
};
}


switch (ext.extType) {
case AREA_SELECT:
data= Object.assign(data,getTwoPointSelectObj(plot,cc,PlotAttribute.SELECTION));
break;
case LINE_SELECT:
data= Object.assign(data,getTwoPointSelectObj(plot,cc,PlotAttribute.ACTIVE_DISTANCE));
break;
case POINT:
data= Object.assign(data,getPointSelectObj(plot,cc));
break;
}

return data;
}

function getTwoPointSelectObj(plot,cc,attribute) {
if (!plot.attributes[attribute]) return {};
var {pt0,pt1}=plot.attributes[attribute];
if (!pt0 && !pt1) return {};

var data= {};
var ipt0= cc.getImageCoords(pt0);
var ipt1= cc.getImageCoords(pt1);
if (ipt0 && ipt1) {
data.ipt0= ipt0.toString();
data.ipt1= ipt1.toString();
}

var wpt0= cc.getWorldCoords(pt0);
var wpt1= cc.getWorldCoords(pt1);
if (wpt0 && wpt1) {
data.wpt0= wpt0.toString();
data.wpt1= wpt1.toString();
}
return data;

}



function getPointSelectObj(plot,cc) {
if (!plot.attributes[PlotAttribute.ACTIVE_POINT]) return {};
var {pt}=plot.attributes[PlotAttribute.ACTIVE_POINT];
if (!pt) return {};

var data= {};
var ipt= cc.getImageCoords(pt);
if (ipt) data.ipt= ipt.toString();

var wpt= cc.getWorldCoords(pt);
if (wpt) data.wpt= wpt.toString();
return data;

}



5 changes: 3 additions & 2 deletions src/firefly/js/core/ReduxFlux.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import createSagaMiddleware from 'redux-saga';
import thunkMiddleware from 'redux-thunk';
import loggerMiddleware from 'redux-logger';
import { createStore, applyMiddleware, combineReducers } from 'redux';
import {dispatchAddSaga} from './MasterSaga.js';
import {masterSaga, dispatchAddSaga} from './MasterSaga.js';
import AppDataCntlr from './AppDataCntlr.js';
import BackgroundCntlr from './background/BackgroundCntlr.js';
import * as LayoutCntlr from './LayoutCntlr.js';
Expand All @@ -32,7 +32,6 @@ import DrawLayerFactory from '../visualize/draw/DrawLayerFactory.js';
import DrawLayerCntlr from '../visualize/DrawLayerCntlr.js';
import MultiViewCntlr, {IMAGE_MULTI_VIEW_KEY} from '../visualize/MultiViewCntlr.js';
import ComponentCntlr, {DIALOG_OR_COMPONENT_KEY} from '../core/ComponentCntlr.js';
import {masterSaga} from './MasterSaga.js';



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



Expand Down Expand Up @@ -226,6 +226,7 @@ function startCoreSagas() {
dispatchAddSaga( syncCharts);
dispatchAddSaga( watchReadout);
dispatchAddSaga( watchForRelatedActions);
dispatchAddSaga( watchExtensionActions);
}

function bootstrap() {
Expand Down
44 changes: 44 additions & 0 deletions src/firefly/js/core/messaging/ExternalAccessWatcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
*/

import {take} from 'redux-saga/effects';
import {isEmpty, isUndefined} from 'lodash';
import {flux} from '../../Firefly.js';
import ExternalAccessCntlr from '../ExternalAccessCntlr.js';
import {makePlotSelectionExtActivateData} from '../ExternalAccessUtils.js';
import {dispatchExtensionActivate} from '../ExternalAccessCntlr.js';
import {getTblRowAsObj, getTblById} from '../../tables/TableUtil.js';
import {DATA_PREFIX, RESULTS_PREFIX, TABLE_HIGHLIGHT} from '../../tables/TablesCntlr.js';



export function* watchExtensionActions() {

while (true) {

const action= yield take();


var {extensionList}= flux.getState()[ExternalAccessCntlr.EXTERNAL_ACCESS_KEY];
if (!isEmpty(extensionList)) {
extensionList
.filter((e) => e.extType === action.type)
.forEach((ext) => dispatchExtensionActivate(ext, makeExtData(ext, action.payload)));
}

}
}



function makeExtData(ext, payload) {
var data= {
id : ext.id,
type: ext.extType
};
if (data.type && data.type.startsWith(DATA_PREFIX) || data.type.startsWith(RESULTS_PREFIX)) {
data.row= getTblRowAsObj( getTblById(payload.tbl_id, payload.highlightedRow));
}
return Object.assign(data,payload);
}
3 changes: 2 additions & 1 deletion src/firefly/js/data/MetaConst.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const MetaConst = {
DATA_PRIMARY : 'DataPrimary',
CATALOG_TARGET_COL_NAME : 'CatalogTargetColName',
CATALOG_COORD_COLS : 'CatalogCoordColumns',
MOVING_COORD_COLS : 'MovingObjCoordColumns',
POSITION_COORD_COLS : 'positionCoordColumns',
POSITION_COORD: 'positionCoord',
DATASET_CONVERTER : 'datasetInfoConverterId',
DEFAULT_COLOR : 'DEFAULT_COLOR',
DATA_SOURCE : 'DataSource'
Expand Down
Loading