Skip to content

Commit 692b94a

Browse files
committed
DM-7986: fix circles connecting & add way to reorder image tabs
1 parent d1bffbf commit 692b94a

File tree

5 files changed

+94
-86
lines changed

5 files changed

+94
-86
lines changed

src/firefly/html/firefly.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
//{label:'Help', action:'app_data.helpLoad', type:'COMMAND'},
2121
]
2222
},
23-
MenuItemKeys: {maskOverlay:true}
23+
MenuItemKeys: {maskOverlay:true},
24+
imageTabs: [ 'fileUpload', 'url', '2mass', 'wise', 'sdss', 'msx', 'dss', 'iras' ]
2425
};
2526
</script>
2627
<script type="text/javascript" src="firefly_loader.js"></script>

src/firefly/js/visualize/draw/DrawUtil.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,13 @@ function drawSymbol(ctx, x, y, drawParams, renderOptions, onlyAddToPath) {
497497
* @param onlyAddToPath
498498
*/
499499
function drawCircle(ctx, x, y, color, lineWidth, size, renderOptions= null, onlyAddToPath= false) {
500-
if (!onlyAddToPath) beginPath(ctx,color,lineWidth, renderOptions);
501500
var radius= size+2;
502-
501+
if (onlyAddToPath) {
502+
ctx.moveTo(x+radius,y);
503+
}
504+
else {
505+
beginPath(ctx, color, lineWidth, renderOptions);
506+
}
503507
ctx.arc(x, y, radius, 0, 2 * Math.PI);
504508
if (!onlyAddToPath) stroke(ctx);
505509
}

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

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44

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

3131
import './ImageSelectPanel.css';
3232

@@ -56,7 +56,23 @@ export const keyMap = {
5656
'plotmode': 'SELECTIMAGEPANEL_targetplot'
5757
};
5858

59-
export const [IRAS, TWOMASS, WISE, MSX, DSS, SDSS, FITS, URL, NONE] = [0, 1, 2, 3, 4, 5, 6, 7, 8];
59+
const findCatId = (ary, id) => get(ary.find( (p) => p.id===id), 'CatalogId',-1);
60+
61+
62+
export const IRAS= findCatId(panelCatalogs,'iras');
63+
export const TWOMASS= findCatId(panelCatalogs,'2mass');
64+
export const WISE= findCatId(panelCatalogs,'wise');
65+
export const MSX= findCatId(panelCatalogs,'msx');
66+
export const DSS= findCatId(panelCatalogs,'dss');
67+
export const SDSS= findCatId(panelCatalogs,'sdss');
68+
export const FITS= findCatId(panelCatalogs,'fileUpload');
69+
export const URL= findCatId(panelCatalogs,'url');
70+
export const NONE= -1;
71+
72+
73+
const defCurrCatalogId= [panelCatalogs[0].CatalogId, panelCatalogs[0].CatalogId, panelCatalogs[0].CatalogId];
74+
75+
6076
export const rgb = ['red', 'green', 'blue'];
6177

6278
export function completeButtonKey( isThreeColor = false ) {
@@ -68,7 +84,8 @@ export function completeButtonKey( isThreeColor = false ) {
6884
*
6985
*/
7086

71-
export function computeCurrentCatalogId( fields, colorFields, catalogId = [IRAS, IRAS, IRAS] ) {
87+
88+
export function computeCurrentCatalogId( fields, colorFields, catalogId = defCurrCatalogId ) {
7289

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

198215
this.state = {
199-
initCatalogId: props.catalogId ? props.catalogId : [IRAS, IRAS, IRAS],
216+
initCatalogId: props.catalogId ? props.catalogId : defCurrCatalogId,
200217
fields: this.allfields[panelKey],
201218
[rgbFieldGroup[RED]]: this.allfields[rgbFieldGroup[RED]],
202219
[rgbFieldGroup[GREEN]]: this.allfields[rgbFieldGroup[GREEN]],
@@ -572,8 +589,9 @@ TargetPanelSetView.defaultProps={
572589
/**
573590
* component inside each catalog tab at middle row
574591
*
575-
* @param {Object} catalog
576-
* @param {Object} fields
592+
* @param {Object} p
593+
* @param {Object} p.catalog
594+
* @param {Object} p.fields
577595
* @returns {XML}
578596
* @constructor
579597
*/

src/firefly/js/visualize/ui/ImageSelectPanelProp.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
/**
22
* Created by cwang on 3/10/16.
33
*/
4-
export const panelCatalogs = [
4+
5+
import {get} from 'lodash';
6+
7+
export const initPanelCatalogs = [
58
{
9+
'id':'iras',
610
'Title':'IRAS',
711
'Symbol': 'IRAS',
812
'CatalogId': 0,
@@ -24,6 +28,7 @@ export const panelCatalogs = [
2428
'size': 5
2529
},
2630
{
31+
'id':'2mass',
2732
'Title':'2MASS',
2833
'Symbol': 'TWOMASS',
2934
'CatalogId': 1,
@@ -40,6 +45,7 @@ export const panelCatalogs = [
4045
'size':.139
4146
},
4247
{
48+
'id': 'wise',
4349
'Title': 'WISE',
4450
'Symbol': 'WISE',
4551
'CatalogId': 2,
@@ -64,6 +70,7 @@ export const panelCatalogs = [
6470
'size':.15
6571
},
6672
{
73+
'id': 'msx',
6774
'Title': 'MSX',
6875
'Symbol': 'MSX',
6976
'CatalogId': 3,
@@ -82,6 +89,7 @@ export const panelCatalogs = [
8289
'size': 1.0
8390
},
8491
{
92+
'id': 'dss',
8593
'Title': 'DSS',
8694
'Symbol': 'DSS',
8795
'CatalogId': 4,
@@ -105,6 +113,7 @@ export const panelCatalogs = [
105113
'size':.25
106114
},
107115
{
116+
'id': 'sdss',
108117
'Title': 'SDSS',
109118
'Symbol': 'SDSS',
110119
'CatalogId': 5,
@@ -124,6 +133,7 @@ export const panelCatalogs = [
124133
'size':.25
125134
},
126135
{
136+
'id': 'fileUpload',
127137
'Title': 'FITS File',
128138
'Symbol': 'FITS',
129139
'CatalogId': 6,
@@ -151,6 +161,7 @@ export const panelCatalogs = [
151161
}
152162
},
153163
{
164+
'id': 'url',
154165
'Title': 'URL',
155166
'Symbol': 'URL',
156167
'CatalogId': 7,
@@ -176,6 +187,28 @@ export const panelCatalogs = [
176187
}
177188
];
178189

190+
191+
const defaultOrder= [
192+
'iras',
193+
'2mass',
194+
'wise',
195+
'msx',
196+
'dss',
197+
'sdss',
198+
'fileUpload',
199+
'url'
200+
];
201+
202+
const order= get(window.firefly, 'imageTabs', defaultOrder);
203+
204+
205+
export const panelCatalogs = order
206+
.map( (id) => initPanelCatalogs.find( (p) => p.id===id))
207+
.filter( (e) => e)
208+
.map ( (e,idx) => Object.assign({},e,{CatalogId:idx}));
209+
210+
211+
179212
/*
180213
blank
181214
{

src/firefly/js/visualize/ui/ImageSelectPanelReducer.js

Lines changed: 28 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import FieldGroupCntlr from '../../fieldGroup/FieldGroupCntlr.js';
99
import {keyMap, computeLabelWidth, rgbFieldGroup, isTargetNeeded,
1010
IRAS, TWOMASS, WISE, MSX, DSS, SDSS, FITS, URL, NONE} from './ImageSelectPanel.jsx';
1111
import {sizeFromDeg} from '../../ui/SizeInputField.jsx';
12-
import {get} from 'lodash';
12+
import {get, isUndefined} from 'lodash';
1313

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

37+
38+
39+
function getTypeData(keyMapId, key, id,value) {
40+
return {
41+
fieldKey: keyMap[keyMapId],
42+
label: get(panelCatalogs[id],[key,'Title'],'Unused'),
43+
value: isUndefined(value) ? get(panelCatalogs[id],[key,'Default'],'') : value,
44+
labelWidth: computeLabelWidth(get(panelCatalogs[id],[key,'Title'],'Unused'))
45+
};
46+
}
47+
48+
3749
// tab fields initialization
3850
function initTabFields(crtCatalogId) {
3951
return (
@@ -42,60 +54,15 @@ function initTabFields(crtCatalogId) {
4254
fieldKey: keyMap['catalogtab'],
4355
value: panelCatalogs[crtCatalogId].CatalogId.toString()
4456
},
45-
[keyMap['irastypes']]: {
46-
fieldKey: keyMap['irastypes'],
47-
label: panelCatalogs[IRAS].types.Title,
48-
value: panelCatalogs[IRAS].types.Default,
49-
labelWidth: computeLabelWidth(panelCatalogs[IRAS].types.Title)
50-
},
51-
[keyMap['twomasstypes']]: {
52-
fieldKey: keyMap['twomasstypes'],
53-
label: panelCatalogs[TWOMASS].types.Title,
54-
value: panelCatalogs[TWOMASS].types.Default,
55-
labelWidth: computeLabelWidth(panelCatalogs[TWOMASS].types.Title)
56-
},
57-
[keyMap['wisetypes']]: {
58-
fieldKey: keyMap['wisetypes'],
59-
label: panelCatalogs[WISE].types.Title,
60-
value: panelCatalogs[WISE].types.Default,
61-
labelWidth: computeLabelWidth(panelCatalogs[WISE].types.Title)
62-
},
63-
[keyMap['wisebands']]: {
64-
fieldKey: keyMap['wisebands'],
65-
label: panelCatalogs[WISE].bands.Title,
66-
value: panelCatalogs[WISE].bands.Default,
67-
labelWidth: computeLabelWidth(panelCatalogs[WISE].bands.Title)
68-
},
69-
[keyMap['msxtypes']]: {
70-
fieldKey: keyMap['msxtypes'],
71-
label: panelCatalogs[MSX].types.Title,
72-
value: panelCatalogs[MSX].types.Default,
73-
labelWidth: computeLabelWidth(panelCatalogs[MSX].types.Title)
74-
},
75-
[keyMap['dsstypes']]: {
76-
fieldKey: keyMap['dsstypes'],
77-
label: panelCatalogs[DSS].types.Title,
78-
value: panelCatalogs[DSS].types.Default,
79-
labelWidth: computeLabelWidth(panelCatalogs[DSS].types.Title)
80-
},
81-
[keyMap['sdsstypes']]: {
82-
fieldKey: keyMap['sdsstypes'],
83-
label: panelCatalogs[SDSS].types.Title,
84-
value: panelCatalogs[SDSS].types.Default,
85-
labelWidth: computeLabelWidth(panelCatalogs[SDSS].types.Title)
86-
},
87-
[keyMap['fitslist']]: {
88-
fieldKey: keyMap['fitslist'],
89-
label: panelCatalogs[FITS].list.Title,
90-
value: panelCatalogs[FITS].list.Default,
91-
labelWidth: computeLabelWidth(panelCatalogs[FITS].list.Title)
92-
},
93-
[keyMap['fitsextinput']]: {
94-
fieldKey: keyMap['fitsextinput'],
95-
label: panelCatalogs[FITS].extinput.Title,
96-
value: '0',
97-
labelWidth: computeLabelWidth(panelCatalogs[FITS].extinput.Title)
98-
},
57+
[keyMap['irastypes']]: getTypeData('irastypes', 'types', IRAS),
58+
[keyMap['twomasstypes']]: getTypeData('twomasstypes', 'types', TWOMASS),
59+
[keyMap['wisetypes']]: getTypeData('wisetypes', 'types', WISE),
60+
[keyMap['wisebands']]: getTypeData('wisebands', 'bands', WISE),
61+
[keyMap['msxtypes']]: getTypeData('msxtypes', 'types', MSX),
62+
[keyMap['dsstypes']]: getTypeData('dsstypes', 'types', DSS),
63+
[keyMap['sdsstypes']]: getTypeData('sdsstypes', 'types', SDSS),
64+
[keyMap['fitslist']]: getTypeData('fitslist', 'list', FITS),
65+
[keyMap['fitsextinput']]: getTypeData('fitsextinput', 'extinput', FITS, '0'),
9966
/*
10067
[keyMap['blankinput']]: {
10168
fieldKey: keyMap['blankinput'],
@@ -107,26 +74,11 @@ function initTabFields(crtCatalogId) {
10774
labelWidth: computeLabelWidth(panelCatalogs[BLANK].input.Title)
10875
},
10976
*/
110-
[keyMap['urlinput']]: {
111-
fieldKey: keyMap['urlinput'],
112-
label: panelCatalogs[URL].input.Title,
113-
validator: Validate.validateUrl.bind(null, 'a url field'),
114-
value: '',
115-
labelWidth: computeLabelWidth(panelCatalogs[URL].input.Title)
116-
},
117-
[keyMap['urllist']]: {
118-
fieldKey: keyMap['urllist'],
119-
label: panelCatalogs[URL].list.Title,
120-
value: panelCatalogs[URL].list.Default,
121-
labelWidth: computeLabelWidth(panelCatalogs[URL].list.Title)
122-
123-
},
124-
[keyMap['urlextinput']]: {
125-
fieldKey: keyMap['urlextinput'],
126-
label: panelCatalogs[URL].extinput.Title,
127-
value: '0',
128-
labelWidth: computeLabelWidth(panelCatalogs[URL].extinput.Title)
129-
}
77+
[keyMap['urlinput']]: Object.assign(
78+
getTypeData('urlinput', 'input', URL,''),
79+
{validator: Validate.validateUrl.bind(null, 'a url field')}),
80+
[keyMap['urllist']]: getTypeData('urllist', 'list', FITS),
81+
[keyMap['urlextinput']]: getTypeData('urlextinput', 'extinput', URL, '0'),
13082
});
13183
}
13284

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

0 commit comments

Comments
 (0)