Skip to content

DM-7986: fix circles connecting & add way to reorder image tabs #208

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
Oct 14, 2016
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
3 changes: 2 additions & 1 deletion src/firefly/html/firefly.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
//{label:'Help', action:'app_data.helpLoad', type:'COMMAND'},
]
},
MenuItemKeys: {maskOverlay:true}
MenuItemKeys: {maskOverlay:true},
imageTabs: [ 'fileUpload', 'url', '2mass', 'wise', 'sdss', 'msx', 'dss', 'iras' ]
};
</script>
<script type="text/javascript" src="firefly_loader.js"></script>
Expand Down
8 changes: 6 additions & 2 deletions src/firefly/js/visualize/draw/DrawUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,13 @@ function drawSymbol(ctx, x, y, drawParams, renderOptions, onlyAddToPath) {
* @param onlyAddToPath
*/
function drawCircle(ctx, x, y, color, lineWidth, size, renderOptions= null, onlyAddToPath= false) {
if (!onlyAddToPath) beginPath(ctx,color,lineWidth, renderOptions);
var radius= size+2;

if (onlyAddToPath) {
ctx.moveTo(x+radius,y);
}
else {
beginPath(ctx, color, lineWidth, renderOptions);
}
ctx.arc(x, y, radius, 0, 2 * Math.PI);
if (!onlyAddToPath) stroke(ctx);
}
Expand Down
30 changes: 24 additions & 6 deletions src/firefly/js/visualize/ui/ImageSelectPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

import React, {Component, PropTypes} from 'react';
import {get} from 'lodash';
import {flux} from '../../Firefly.js';
import {visRoot } from '../ImagePlotCntlr.js';
import {NewPlotMode, getAViewFromMultiView, findViewerWithItemId,
Expand All @@ -26,7 +27,6 @@ import {resultSuccess, resultFail} from './ImageSelectPanelResult.js';
import {getActivePlotView, primePlot} from '../PlotViewUtil.js';
import {FieldGroupCollapsible, CollapseBorder, CollapseHeaderCorner} from '../../ui/panel/CollapsiblePanel.jsx';
import {ImageSelPanelChangeOneColor, ImageSelPanelChange} from './ImageSelectPanelReducer.js';
import {get} from 'lodash';

import './ImageSelectPanel.css';

Expand Down Expand Up @@ -56,7 +56,23 @@ export const keyMap = {
'plotmode': 'SELECTIMAGEPANEL_targetplot'
};

export const [IRAS, TWOMASS, WISE, MSX, DSS, SDSS, FITS, URL, NONE] = [0, 1, 2, 3, 4, 5, 6, 7, 8];
const findCatId = (ary, id) => get(ary.find( (p) => p.id===id), 'CatalogId',-1);


export const IRAS= findCatId(panelCatalogs,'iras');
export const TWOMASS= findCatId(panelCatalogs,'2mass');
export const WISE= findCatId(panelCatalogs,'wise');
export const MSX= findCatId(panelCatalogs,'msx');
export const DSS= findCatId(panelCatalogs,'dss');
export const SDSS= findCatId(panelCatalogs,'sdss');
export const FITS= findCatId(panelCatalogs,'fileUpload');
export const URL= findCatId(panelCatalogs,'url');
export const NONE= -1;


const defCurrCatalogId= [panelCatalogs[0].CatalogId, panelCatalogs[0].CatalogId, panelCatalogs[0].CatalogId];


export const rgb = ['red', 'green', 'blue'];

export function completeButtonKey( isThreeColor = false ) {
Expand All @@ -68,7 +84,8 @@ export function completeButtonKey( isThreeColor = false ) {
*
*/

export function computeCurrentCatalogId( fields, colorFields, catalogId = [IRAS, IRAS, IRAS] ) {

export function computeCurrentCatalogId( fields, colorFields, catalogId = defCurrCatalogId ) {

const keytab = keyMap['catalogtab'];
var newId = catalogId.slice();
Expand Down Expand Up @@ -196,7 +213,7 @@ export class ImageSelection extends Component {
this.allfields = getAllGroupFields(panelKey,...rgbFieldGroup);

this.state = {
initCatalogId: props.catalogId ? props.catalogId : [IRAS, IRAS, IRAS],
initCatalogId: props.catalogId ? props.catalogId : defCurrCatalogId,
fields: this.allfields[panelKey],
[rgbFieldGroup[RED]]: this.allfields[rgbFieldGroup[RED]],
[rgbFieldGroup[GREEN]]: this.allfields[rgbFieldGroup[GREEN]],
Expand Down Expand Up @@ -585,8 +602,9 @@ TargetPanelSetView.defaultProps={
/**
* component inside each catalog tab at middle row
*
* @param {Object} catalog
* @param {Object} fields
* @param {Object} p
* @param {Object} p.catalog
* @param {Object} p.fields
* @returns {XML}
* @constructor
*/
Expand Down
35 changes: 34 additions & 1 deletion src/firefly/js/visualize/ui/ImageSelectPanelProp.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/**
* Created by cwang on 3/10/16.
*/
export const panelCatalogs = [

import {get} from 'lodash';

export const initPanelCatalogs = [
{
'id':'iras',
'Title':'IRAS',
'Symbol': 'IRAS',
'CatalogId': 0,
Expand All @@ -24,6 +28,7 @@ export const panelCatalogs = [
'size': 5
},
{
'id':'2mass',
'Title':'2MASS',
'Symbol': 'TWOMASS',
'CatalogId': 1,
Expand All @@ -40,6 +45,7 @@ export const panelCatalogs = [
'size':.139
},
{
'id': 'wise',
'Title': 'WISE',
'Symbol': 'WISE',
'CatalogId': 2,
Expand All @@ -64,6 +70,7 @@ export const panelCatalogs = [
'size':.15
},
{
'id': 'msx',
'Title': 'MSX',
'Symbol': 'MSX',
'CatalogId': 3,
Expand All @@ -82,6 +89,7 @@ export const panelCatalogs = [
'size': 1.0
},
{
'id': 'dss',
'Title': 'DSS',
'Symbol': 'DSS',
'CatalogId': 4,
Expand All @@ -105,6 +113,7 @@ export const panelCatalogs = [
'size':.25
},
{
'id': 'sdss',
'Title': 'SDSS',
'Symbol': 'SDSS',
'CatalogId': 5,
Expand All @@ -124,6 +133,7 @@ export const panelCatalogs = [
'size':.25
},
{
'id': 'fileUpload',
'Title': 'FITS File',
'Symbol': 'FITS',
'CatalogId': 6,
Expand Down Expand Up @@ -151,6 +161,7 @@ export const panelCatalogs = [
}
},
{
'id': 'url',
'Title': 'URL',
'Symbol': 'URL',
'CatalogId': 7,
Expand All @@ -176,6 +187,28 @@ export const panelCatalogs = [
}
];


const defaultOrder= [
'iras',
'2mass',
'wise',
'msx',
'dss',
'sdss',
'fileUpload',
'url'
];

const order= get(window.firefly, 'imageTabs', defaultOrder);


export const panelCatalogs = order
.map( (id) => initPanelCatalogs.find( (p) => p.id===id))
.filter( (e) => e)
.map ( (e,idx) => Object.assign({},e,{CatalogId:idx}));



/*
blank
{
Expand Down
104 changes: 28 additions & 76 deletions src/firefly/js/visualize/ui/ImageSelectPanelReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import FieldGroupCntlr from '../../fieldGroup/FieldGroupCntlr.js';
import {keyMap, computeLabelWidth, rgbFieldGroup, isTargetNeeded,
IRAS, TWOMASS, WISE, MSX, DSS, SDSS, FITS, URL, NONE} from './ImageSelectPanel.jsx';
import {sizeFromDeg} from '../../ui/SizeInputField.jsx';
import {get} from 'lodash';
import {get, isUndefined} from 'lodash';

// get unit (string), min (float) and max (float) from the data file
var getRangeItem = (crtCatalogId, rangeItem) => {
Expand All @@ -34,6 +34,18 @@ var getSize = (crtCatalogId) => {
}
};



function getTypeData(keyMapId, key, id,value) {
return {
fieldKey: keyMap[keyMapId],
label: get(panelCatalogs[id],[key,'Title'],'Unused'),
value: isUndefined(value) ? get(panelCatalogs[id],[key,'Default'],'') : value,
labelWidth: computeLabelWidth(get(panelCatalogs[id],[key,'Title'],'Unused'))
};
}


// tab fields initialization
function initTabFields(crtCatalogId) {
return (
Expand All @@ -42,60 +54,15 @@ function initTabFields(crtCatalogId) {
fieldKey: keyMap['catalogtab'],
value: panelCatalogs[crtCatalogId].CatalogId.toString()
},
[keyMap['irastypes']]: {
fieldKey: keyMap['irastypes'],
label: panelCatalogs[IRAS].types.Title,
value: panelCatalogs[IRAS].types.Default,
labelWidth: computeLabelWidth(panelCatalogs[IRAS].types.Title)
},
[keyMap['twomasstypes']]: {
fieldKey: keyMap['twomasstypes'],
label: panelCatalogs[TWOMASS].types.Title,
value: panelCatalogs[TWOMASS].types.Default,
labelWidth: computeLabelWidth(panelCatalogs[TWOMASS].types.Title)
},
[keyMap['wisetypes']]: {
fieldKey: keyMap['wisetypes'],
label: panelCatalogs[WISE].types.Title,
value: panelCatalogs[WISE].types.Default,
labelWidth: computeLabelWidth(panelCatalogs[WISE].types.Title)
},
[keyMap['wisebands']]: {
fieldKey: keyMap['wisebands'],
label: panelCatalogs[WISE].bands.Title,
value: panelCatalogs[WISE].bands.Default,
labelWidth: computeLabelWidth(panelCatalogs[WISE].bands.Title)
},
[keyMap['msxtypes']]: {
fieldKey: keyMap['msxtypes'],
label: panelCatalogs[MSX].types.Title,
value: panelCatalogs[MSX].types.Default,
labelWidth: computeLabelWidth(panelCatalogs[MSX].types.Title)
},
[keyMap['dsstypes']]: {
fieldKey: keyMap['dsstypes'],
label: panelCatalogs[DSS].types.Title,
value: panelCatalogs[DSS].types.Default,
labelWidth: computeLabelWidth(panelCatalogs[DSS].types.Title)
},
[keyMap['sdsstypes']]: {
fieldKey: keyMap['sdsstypes'],
label: panelCatalogs[SDSS].types.Title,
value: panelCatalogs[SDSS].types.Default,
labelWidth: computeLabelWidth(panelCatalogs[SDSS].types.Title)
},
[keyMap['fitslist']]: {
fieldKey: keyMap['fitslist'],
label: panelCatalogs[FITS].list.Title,
value: panelCatalogs[FITS].list.Default,
labelWidth: computeLabelWidth(panelCatalogs[FITS].list.Title)
},
[keyMap['fitsextinput']]: {
fieldKey: keyMap['fitsextinput'],
label: panelCatalogs[FITS].extinput.Title,
value: '0',
labelWidth: computeLabelWidth(panelCatalogs[FITS].extinput.Title)
},
[keyMap['irastypes']]: getTypeData('irastypes', 'types', IRAS),
[keyMap['twomasstypes']]: getTypeData('twomasstypes', 'types', TWOMASS),
[keyMap['wisetypes']]: getTypeData('wisetypes', 'types', WISE),
[keyMap['wisebands']]: getTypeData('wisebands', 'bands', WISE),
[keyMap['msxtypes']]: getTypeData('msxtypes', 'types', MSX),
[keyMap['dsstypes']]: getTypeData('dsstypes', 'types', DSS),
[keyMap['sdsstypes']]: getTypeData('sdsstypes', 'types', SDSS),
[keyMap['fitslist']]: getTypeData('fitslist', 'list', FITS),
[keyMap['fitsextinput']]: getTypeData('fitsextinput', 'extinput', FITS, '0'),
/*
[keyMap['blankinput']]: {
fieldKey: keyMap['blankinput'],
Expand All @@ -107,26 +74,11 @@ function initTabFields(crtCatalogId) {
labelWidth: computeLabelWidth(panelCatalogs[BLANK].input.Title)
},
*/
[keyMap['urlinput']]: {
fieldKey: keyMap['urlinput'],
label: panelCatalogs[URL].input.Title,
validator: Validate.validateUrl.bind(null, 'a url field'),
value: '',
labelWidth: computeLabelWidth(panelCatalogs[URL].input.Title)
},
[keyMap['urllist']]: {
fieldKey: keyMap['urllist'],
label: panelCatalogs[URL].list.Title,
value: panelCatalogs[URL].list.Default,
labelWidth: computeLabelWidth(panelCatalogs[URL].list.Title)

},
[keyMap['urlextinput']]: {
fieldKey: keyMap['urlextinput'],
label: panelCatalogs[URL].extinput.Title,
value: '0',
labelWidth: computeLabelWidth(panelCatalogs[URL].extinput.Title)
}
[keyMap['urlinput']]: Object.assign(
getTypeData('urlinput', 'input', URL,''),
{validator: Validate.validateUrl.bind(null, 'a url field')}),
[keyMap['urllist']]: getTypeData('urllist', 'list', FITS),
[keyMap['urlextinput']]: getTypeData('urlextinput', 'extinput', URL, '0'),
});
}

Expand Down Expand Up @@ -188,7 +140,7 @@ var initTargetSize = (crtCatalogId) => {
// reducer for the child field group (fieldgrouptabs for r, g, b)
export var ImageSelPanelChangeOneColor = (inFields, action) => {
if (!inFields) {
return initTabFields(IRAS);
return initTabFields(panelCatalogs[0].CatalogId);
} else {
return inFields;
}
Expand Down