Skip to content

Commit dfa94a0

Browse files
committed
DM-7273: fixed conflicts
2 parents d6721c4 + 6ba7fe9 commit dfa94a0

File tree

9 files changed

+76
-32
lines changed

9 files changed

+76
-32
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@
195195
}
196196
];
197197

198+
//util.image.setDrawLayerDefaults('ACTIVE_TARGET_TYPE', {symbol:'x', color:'pINk'});
199+
//util.image.setDrawLayerDefaults('CATALOG_TYPE', {symbol:'ARROW', color:'pink', size:10});
198200

199201
firefly.showImage('imageViewHere', req);
200202
firefly.showImage('imageViewHere', req2);

src/firefly/js/api/ApiUtilImage.jsx

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@ import {MouseState} from '../visualize/VisMouseSync.js';
99
import ImagePlotCntlr, {visRoot, ExpandType} from '../visualize/ImagePlotCntlr.js';
1010
import {primePlot} from '../visualize/PlotViewUtil.js';
1111
import {dispatchAddSaga} from '../core/MasterSaga.js';
12-
import {DefaultApiReadout} from '../visualize/ui/DefaultApiReadout.jsx';
13-
//import {PopupMouseReadoutMinimal} from '../visualize/ui/PopupMouseReadoutMinimal.jsx';
14-
import {PopupMouseReadoutFull} from '../visualize/ui/PopupMouseReadoutFull.jsx';
12+
import {DefaultApiReadout} from '../visualize/ui/DefaultApiReadout.jsx';
13+
import {reduxFlux} from '../core/ReduxFlux.js';
14+
import {PopupMouseReadoutFull} from '../visualize/ui/PopupMouseReadoutFull.jsx';
1515
import DialogRootContainer from '../ui/DialogRootContainer.jsx';
1616
import {PopupPanel, LayoutType} from '../ui/PopupPanel.jsx';
1717
import {dispatchShowDialog,dispatchHideDialog, isDialogVisible} from '../core/ComponentCntlr.js';
1818
import {readoutRoot,isAutoReadIsLocked, isLockByClick,STANDARD_READOUT} from '../visualize/MouseReadoutCntlr.js';
1919
import {mouseUpdatePromise} from '../visualize/VisMouseSync.js';
2020
import {RangeValues} from '../visualize/RangeValues.js';
21+
22+
23+
2124
const API_READOUT= 'apiReadout';
2225

2326
// NOTE
@@ -48,7 +51,7 @@ export {extensionAdd, extensionRemove} from '../core/ExternalAccessUtils.js';
4851

4952

5053
/**
51-
* @summary Get plot object with the given plot id, when plotId is not included, active plot is returned.
54+
* Get plot object with the given plot id, when plotId is not included, active plot is returned.
5255
* @param {string} [plotId] the plotId, optional
5356
* @returns {WebPlot}
5457
* @public
@@ -64,8 +67,28 @@ export function getPrimePlot(plotId) {
6467

6568
var isInit= false;
6669
/**
67-
* @summary initialize the auto readout. Can only be called once at the begging to get the popup readout running.
68-
* Called internally during first image plot.
70+
* Set a defaults object on for a draw layer type.
71+
* The following draw layers are supported: 'ACTIVE_TARGET_TYPE', 'CATALOG_TYPE'
72+
* @param {string} drawLayerTypeId
73+
* @param {DrawingDef} defaults
74+
* @public
75+
* @function setDrawLayerDefaults
76+
* @memberof firefly.util.image
77+
*
78+
* @example
79+
* firefly.util.image.setDrawLayerDefaults('ACTIVE_TARGET_TYPE', {symbol:'x', color:'pink', size:15});
80+
* or
81+
* firefly util.image.setDrawLayerDefaults('CATALOG_TYPE', {symbol:'cross', color:'red'});
82+
*
83+
* @see DrawingDef
84+
* @see DrawSymbol
85+
*/
86+
export function setDrawLayerDefaults(drawLayerTypeId, defaults) {
87+
reduxFlux.setDrawLayerDefaults(drawLayerTypeId, defaults);
88+
}
89+
90+
/**
91+
* @summary initialize the auto readout. Must be call once at the begging to get the popup readout running.
6992
* @param {object} ReadoutComponent - either a PopupMouseReadoutMinimal or PopupMouseReadoutFull
7093
* @param {object} props - a list of the properties
7194
* @public

src/firefly/js/core/ReduxFlux.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ function registerDrawLayer(factoryDef) {
314314
drawLayerFactory.register(factoryDef);
315315
}
316316

317+
function setDrawLayerDefaults(typeId,defaults) {
318+
drawLayerFactory.setDrawLayerDefaults(typeId,defaults);
319+
}
320+
317321
function createDrawLayer(drawLayerTypeId, params) {
318322
return drawLayerFactory.create(drawLayerTypeId,params);
319323
}
@@ -329,6 +333,7 @@ export var reduxFlux = {
329333
registerDrawLayer,
330334
createDrawLayer,
331335
getDrawLayerFactory,
336+
setDrawLayerDefaults,
332337
getRedux
333338
};
334339

src/firefly/js/drawingLayers/ActiveTarget.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ export default {factoryDef, TYPE_ID}; // every draw layer must default export wi
2525
var idCnt=0;
2626

2727

28-
function creator(initPayload) {
28+
function creator(initPayload, presetDefaults) {
2929
var drawingDef= makeDrawingDef('blue');
3030
drawingDef.symbol= DrawSymbol.SQUARE;
31+
drawingDef= Object.assign(drawingDef,presetDefaults);
32+
3133
idCnt++;
3234

3335
var options= {

src/firefly/js/drawingLayers/Catalog.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ var createCnt= 0;
4848
//---------------------------------------------------------------------
4949

5050

51-
function creator(initPayload) {
51+
function creator(initPayload, presetDefaults) {
5252
const {catalogId, tableData, tableMeta, title,
5353
selectInfo, columns, tableRequest, highlightedRow, color, angleInRadian=false,
5454
dataTooBigForSelection=false, catalog=true,boxData=false }= initPayload;
5555
var drawingDef= makeDrawingDef();
56+
drawingDef.size= 5;
5657
drawingDef.symbol= DrawSymbol.SQUARE;
58+
drawingDef= Object.assign(drawingDef,presetDefaults);
5759

5860
var pairs= {
5961
[MouseState.DOWN.key]: highlightChange
@@ -220,9 +222,10 @@ function computePointDrawLayer(drawLayer, tableData, columns) {
220222
const {angleInRadian:rad}= drawLayer;
221223
if (lonIdx<0 || latIdx<0) return null;
222224

225+
const {size,symbol}= drawLayer.drawingDef;
223226
return tableData.data.map( (d) => {
224227
const wp= makeWorldPt( toAngle(d[lonIdx],rad), toAngle(d[latIdx],rad), columns.csys);
225-
return PointDataObj.make(wp, 5, DrawSymbol.SQUARE);
228+
return PointDataObj.make(wp, size, symbol);
226229
});
227230
}
228231

@@ -266,7 +269,7 @@ function computePointHighlightLayer(drawLayer, columns) {
266269
if (!raStr || !decStr) return null;
267270

268271
const wp= makeWorldPt( raStr, decStr, columns.csys);
269-
const obj= PointDataObj.make(wp, 5, DrawSymbol.SQUARE);
272+
const obj= PointDataObj.make(wp, 5, drawLayer.drawingDef.symbol);
270273
const obj2= PointDataObj.make(wp, 5, DrawSymbol.X);
271274
obj.color= COLOR_HIGHLIGHTED_PT;
272275
obj2.color= COLOR_HIGHLIGHTED_PT;

src/firefly/js/visualize/WebPlotRequest.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,12 @@ export class WebPlotRequest extends ServerRequest {
269269
return req;
270270
}
271271

272-
static makeProcessorRequest(serverRequest, desc) {
272+
static makeProcessorRequest(obj, desc) {
273273
var req = new WebPlotRequest(RequestType.PROCESSOR, desc);
274-
// req.setParams(serverRequest.getParams());
275-
req.setParams(serverRequest.getParams());
274+
req.setParams(obj);
276275
return req;
277276
}
278277

279-
280278
static makeURLPlotRequest(url, userDesc) {
281279
var req = new WebPlotRequest(RequestType.URL, userDesc||'Fits from URL: ' + url);
282280
req.setTitleOptions(TitleOptions.FILE_NAME);

src/firefly/js/visualize/draw/DrawLayerFactory.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class DrawLayerFactory {
8989

9090
constructor(factoryDefsAry) {
9191
this.registry= {};
92+
this.defaults= {};
9293
factoryDefsAry.forEach( (fd) => {
9394
if (fd.create && fd.drawLayerTypeId) {
9495
this.register(fd);
@@ -111,7 +112,7 @@ class DrawLayerFactory {
111112
console.warn(`DrawingLayerType: ${drawLayerTypeId} does not exist in the registry, did you forget to add it?`);
112113
return null;
113114
}
114-
return this.registry[drawLayerTypeId].create(initPayload);
115+
return this.registry[drawLayerTypeId].create(initPayload, this.defaults[drawLayerTypeId]);
115116
}
116117

117118
hasGetDrawData(drawLayer) {
@@ -148,6 +149,11 @@ class DrawLayerFactory {
148149
return this.registry[drawLayer.drawLayerTypeId].getUIComponent;
149150
}
150151

152+
setDrawLayerDefaults(drawLayerTypeId, def) {
153+
if (this.defaults[drawLayerTypeId]) {
154+
this.defaults[drawLayerTypeId]= Object.assign(this.defaults[drawLayerTypeId], def);
155+
}
156+
}
151157

152158

153159
/**
@@ -156,6 +162,7 @@ class DrawLayerFactory {
156162
*/
157163
register(factoryDef) {
158164
this.registry[factoryDef.drawLayerTypeId]= factoryDef;
165+
this.defaults[factoryDef.drawLayerTypeId]= {};
159166
}
160167

161168
static makeFactory(...factoryDefs) {

src/firefly/js/visualize/draw/DrawingDef.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ export const DEFAULT_FONT_SIZE = '9pt';
5454
/**
5555
* @typedef {Object} DrawingDef
5656
*
57+
* The defaults that a drawing layer might use. Note that all the properties of this object are optional.
58+
* It can be created with any subset.
59+
*
5760
* @prop {String} color color css style
5861
* @prop {DrawSymbol} symbol default: DrawSymbol.X,
5962
* @prop {Number} lineWidth default:1,
@@ -77,12 +80,12 @@ export const DEFAULT_FONT_SIZE = '9pt';
7780
* @param pointData
7881
* @return {DrawingDef}
7982
*/
80-
export function makeDrawingDef(color= 'red') {
83+
export function makeDrawingDef(color= 'red', presetDefaults= {}) {
8184

8285
// FIXME: those are not DS9 colors, hence problem when saved in DS9 regions format file
8386

8487

85-
return {
88+
const def= {
8689
color,
8790
symbol: DrawSymbol.X,
8891
lineWidth:1,
@@ -95,6 +98,7 @@ export function makeDrawingDef(color= 'red') {
9598
fontStyle: 'normal',
9699
selectedColor: COLOR_SELECTED_PT
97100
};
101+
return Object.assign({}, def, presetDefaults);
98102
}
99103

100104

src/firefly/js/visualize/draw/PointDataObj.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ import {defaultRegionSelectColor, defaultRegionSelectStyle} from '../DrawLayerCn
2121

2222
/**
2323
* enum
24-
* ROTATE is the symbol mainly used as an indication for rotation in drawing layer
2524
* one of 'X','SQUARE','CROSS','DIAMOND','DOT','CIRCLE', 'SQUARE_X', 'EMP_CROSS','EMP_SQUARE_X', 'BOXCIRCLE', 'ARROW'
2625
* */
2726
export const DrawSymbol = new Enum([
2827
'X','SQUARE','CROSS','DIAMOND','DOT','CIRCLE', 'SQUARE_X', 'EMP_CROSS','EMP_SQUARE_X',
2928
'BOXCIRCLE', 'ARROW', 'ROTATE'
30-
]);
29+
], { ignoreCase: true });
3130

3231
export const POINT_DATA_OBJ= 'PointDataObj';
3332
const DEFAULT_SIZE= 4;
@@ -70,7 +69,8 @@ var draw= {
7069

7170
usePathOptimization(drawObj) {
7271
if (!drawObj.symbol) return true;
73-
return drawObj.symbol!=DrawSymbol.EMP_CROSS && drawObj.symbol!=DrawSymbol.EMP_SQUARE_X;
72+
const s= DrawSymbol.get(drawObj.symbol);
73+
return s!==DrawSymbol.EMP_CROSS && s!==DrawSymbol.EMP_SQUARE_X;
7474
},
7575

7676
getCenterPt(drawObj) {return drawObj.pt; },
@@ -125,7 +125,7 @@ export default {make,draw};
125125

126126
/**
127127
* translate the point symbol
128-
* @param plot
128+
* @param {WebPlot} plot
129129
* @param drawObj
130130
* @param apt
131131
* @returns {{pt: *}}
@@ -139,10 +139,10 @@ function translatePtTo(plot, drawObj, apt) {
139139
/**
140140
* rotate the point symbol (rotate the point defined for the point, not the entire symbol)
141141
* if the entire symbol needs to be rotated, set the angle to renderOptions.rotAngle externally
142-
* @param plot
142+
* @param {WebPlot} plot
143143
* @param drawObj
144-
* @param angle in screen coodinate direction, radian
145-
* @param worldPt
144+
* @param {number} angle in screen coodinate direction, radian
145+
* @param {WorldPt} worldPt
146146
* @returns {{pt: *}}
147147
*/
148148
function rotatePtAround(plot, drawObj, angle, worldPt) {
@@ -153,14 +153,14 @@ function rotatePtAround(plot, drawObj, angle, worldPt) {
153153

154154

155155
function makeDrawParams(pointDataObj,def) {
156-
var symbol= pointDataObj.symbol || def.symbol || DEFAULT_SYMBOL;
157-
var size= (symbol===DrawSymbol.DOT) ? pointDataObj.size || def.size || DOT_DEFAULT_SIZE :
156+
const symbol= DrawSymbol.get(pointDataObj.symbol || def.symbol || DEFAULT_SYMBOL);
157+
const size= (symbol===DrawSymbol.DOT) ? pointDataObj.size || def.size || DOT_DEFAULT_SIZE :
158158
pointDataObj.size || def.size || DEFAULT_SIZE;
159-
var fontName= pointDataObj.fontName || def.fontName || 'helvetica';
160-
var fontSize= pointDataObj.fontSize || def.fontSize || DEFAULT_FONT_SIZE;
161-
var fontWeight= pointDataObj.fontWeight || def.fontWeight || 'normal';
162-
var fontStyle= pointDataObj.fontStyle || def.fontStyle || 'normal';
163-
var textLoc= pointDataObj.textLoc || def.textLoc || TextLocation.DEFAULT;
159+
const fontName= pointDataObj.fontName || def.fontName || 'helvetica';
160+
const fontSize= pointDataObj.fontSize || def.fontSize || DEFAULT_FONT_SIZE;
161+
const fontWeight= pointDataObj.fontWeight || def.fontWeight || 'normal';
162+
const fontStyle= pointDataObj.fontStyle || def.fontStyle || 'normal';
163+
const textLoc= pointDataObj.textLoc || def.textLoc || TextLocation.DEFAULT;
164164

165165
return {
166166
color: DrawUtil.getColor(pointDataObj.color,def.color),
@@ -179,7 +179,7 @@ function makeDrawParams(pointDataObj,def) {
179179
* @param ctx
180180
* @param drawTextAry
181181
* @param pt
182-
* @param plot
182+
* @param {WebPlot} plot
183183
* @param drawObj
184184
* @param drawParams
185185
* @param renderOptions

0 commit comments

Comments
 (0)