Skip to content

Commit db9962b

Browse files
authored
Merge pull request #126 from Caltech-IPAC/dm-7029-api-bugs
DM-7029: fixed some api bugs
2 parents 73efe9f + 0c5e347 commit db9962b

File tree

8 files changed

+61
-26
lines changed

8 files changed

+61
-26
lines changed

src/firefly/js/api/ApiUtilImage.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export {RangeValues} from '../visualize/RangeValues.js';
3131
export {WPConst, WebPlotRequest, findInvalidWPRKeys, confirmPlotRequest} from '../visualize/WebPlotRequest.js';
3232
export {RequestType} from '../visualize/RequestType';
3333
export {ExpandType, dispatchApiToolsView} from '../visualize/ImagePlotCntlr.js';
34+
export {CsysConverter} from '../visualize/CsysConverter.js';
35+
export {CCUtil} from '../visualize/CsysConverter.js';
36+
export {primePlot} from '../visualize/PlotViewUtil.js';
37+
export {visRoot} from '../visualize/ImagePlotCntlr.js';
3438
export {watchCoverage} from '../visualize/saga/CoverageWatcher.js';
3539
import {watchImageMetaData} from '../visualize/saga/ImageMetaDataWatcher.js';
3640

src/firefly/js/drawingLayers/SelectArea.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function creator() {
8484
DrawLayerCntlr.SELECT_AREA_MOVE,
8585
DrawLayerCntlr.SELECT_AREA_END,
8686
DrawLayerCntlr.SELECT_MOUSE_LOC];
87-
87+
8888
var exclusiveDef= { exclusiveOnDown: true, type : 'anywhere' };
8989

9090

@@ -93,7 +93,7 @@ function creator() {
9393
var options= {
9494
canUseMouse:true,
9595
canUserChangeColor: ColorChangeType.DISABLE,
96-
canUserDelete: false,
96+
canUserDelete: true,
9797
destroyWhenAllDetached: true
9898
};
9999
return DrawLayer.makeDrawLayer( `${ID}-${idCnt}`, TYPE_ID, 'Selection Tool',
@@ -259,7 +259,7 @@ function drag(drawLayer,action) {
259259
var plot= primePlot(visRoot(),plotId);
260260
if (!plot) return;
261261
var drawSel= makeSelectObj(drawLayer.firstPt, imagePt, CsysConverter.make(plot));
262-
var exclusiveDef= { exclusiveOnDown: true, type : 'vertexOnly' };
262+
var exclusiveDef= { exclusiveOnDown: true, type : 'vertexThenAnywhere' };
263263
return {currentPt:imagePt,
264264
drawData:{data:drawSel},
265265
exclusiveDef,

src/firefly/js/visualize/PlotImageTask.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import CsysConverter from './CsysConverter.js';
1212
import {dispatchActiveTarget, getActiveTarget} from '../core/AppDataCntlr.js';
1313
import VisUtils from './VisUtil.js';
1414
import {PlotState} from './PlotState.js';
15-
import {makeImagePt} from './Point.js';
15+
import Point, {makeImagePt} from './Point.js';
1616
import {WPConst, DEFAULT_THUMBNAIL_SIZE} from './WebPlotRequest.js';
1717
import {Band} from './Band.js';
1818
import {PlotPref} from './PlotPref.js';
@@ -230,7 +230,7 @@ export function processPlotImageSuccessResponse(dispatcher, payload, result) {
230230

231231
pvNewPlotInfoAry
232232
.forEach((info) => info.plotAry
233-
.forEach( (p) => addDrawLayers(p.plotState.getWebPlotRequest(), p.plotId) ));
233+
.forEach( (p) => addDrawLayers(p.plotState.getWebPlotRequest(), p) ));
234234

235235

236236

@@ -253,10 +253,21 @@ export function processPlotImageSuccessResponse(dispatcher, payload, result) {
253253
}
254254

255255

256-
function addDrawLayers(request, plotId ) {
256+
function addDrawLayers(request, plot ) {
257+
const {plotId}= plot;
257258
request.getOverlayIds().forEach((drawLayerTypeId)=> {
258259
const dl = getDrawLayerByType(dlRoot(), drawLayerTypeId);
259-
if (dl) DrawLayerCntlr.dispatchAttachLayerToPlot(dl.drawLayerId, plotId);
260+
if (dl) {
261+
if (dl.drawLayerTypeId===ActiveTarget.TYPE_ID) {
262+
const pt= plot.attributes[PlotAttribute.FIXED_TARGET];
263+
if (pt && pt.type===Point.W_PT) {
264+
DrawLayerCntlr.dispatchAttachLayerToPlot(dl.drawLayerId, plotId);
265+
}
266+
}
267+
else {
268+
DrawLayerCntlr.dispatchAttachLayerToPlot(dl.drawLayerId, plotId);
269+
}
270+
}
260271
});
261272

262273
if (request.getGridOn()!==GridOnStatus.FALSE) {

src/firefly/js/visualize/draw/DrawerComponent.jsx

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

55
import React from 'react';
6-
import difference from 'lodash/difference';
7-
import isEqual from 'lodash/isEqual';
6+
import {xor,isEqual} from 'lodash';
87
import sCompare from 'react-addons-shallow-compare';
98
import CanvasWrapper from './CanvasWrapper.jsx';
109
import TextDrawer from './TextDrawer.jsx';
@@ -80,7 +79,8 @@ export class DrawerComponent extends React.Component {
8079
textUpdateCallback(textDrawAry) {
8180
var {textDrawAry:old}= this.state;
8281
//if ((!textDrawAry && !old) || !textDrawAry.length && !old.length) return;
83-
if (!difference(textDrawAry,old).length) return;
82+
// if (!difference(textDrawAry,old).length && !difference(old,textDrawAry).length) return;
83+
if (!xor(textDrawAry,old).length) return;
8484

8585
var doUpdate=
8686
old.length!=textDrawAry.length ||

src/firefly/js/visualize/iv/EventLayer.jsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ export var EventLayer= React.createClass(
5050
var {x:viewPortX,y:viewPortY} = viewPort;
5151
var {screenX, screenY, pageX:x, pageY:y}= nativeEv;
5252
var e= ReactDOM.findDOMNode(this);
53-
var compOffX= x-getAbsoluteLeft(e)+window.scrollX-1;
54-
var compOffY= y-getAbsoluteTop(e)+window.scrollY-1;
53+
// var compOffX= x-getAbsoluteLeft(e)+window.scrollX-1;
54+
// var compOffY= y-getAbsoluteTop(e)+window.scrollY-1;
55+
var compOffX= x-getAbsoluteLeft(e);
56+
var compOffY= y-getAbsoluteTop(e);
5557
spt= makeScreenPt( viewPortX+compOffX, viewPortY+compOffY);
5658
this.props.eventCallback(plotId,mouseState,spt,screenX,screenY);
5759
},
@@ -96,6 +98,14 @@ export var EventLayer= React.createClass(
9698

9799
},
98100

101+
102+
onMouseMove(ev) {
103+
if (!this.mouseDown) {
104+
var {viewPort,plotId}= this.props;
105+
this.fireEvent(ev,plotId,viewPort,this.mouseDown?MouseState.DRAG_COMPONENT : MouseState.MOVE);
106+
}
107+
},
108+
99109
onDocumentMouseMove(nativeEv) {
100110
if (this.mouseDown) {
101111
var {viewPort,plotId}= this.props;
@@ -124,11 +134,6 @@ export var EventLayer= React.createClass(
124134
},
125135

126136

127-
onMouseMove(ev) {
128-
var {viewPort,plotId}= this.props;
129-
this.fireEvent(ev,plotId,viewPort,this.mouseDown?MouseState.DRAG_COMPONENT : MouseState.MOVE);
130-
},
131-
132137

133138
onTouchCancel(ev) {
134139
this.mouseDown= false;

src/firefly/js/visualize/iv/ImageViewerLayout.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@ function findMouseOwner(dlList, plot, screenPt) {
309309
const y= screenPt.y- dist;
310310
const w= dist*2;
311311
const h= dist*2;
312-
return vertexDef.points.find( (p) => {
313-
const spt= cc.getScreenCoords(p);
314-
return contains(x,y,w,h,spt.x,spt.y);
312+
return vertexDef.points.find( (pt) => {
313+
const spt= cc.getScreenCoords(pt);
314+
return spt && contains(x,y,w,h,spt.x,spt.y);
315315
} );
316316
});
317317

src/firefly/js/visualize/reducer/PlotView.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,14 +403,19 @@ function getNewAttributes(plot) {
403403
worldPt= circle.center;
404404
}
405405
else if (getActiveTarget()) {
406-
worldPt= getActiveTarget();
406+
worldPt= getActiveTarget().worldPt;
407407
}
408408
else {
409409
worldPt= VisUtil.getCenterPtOfPlot(plot);
410410
}
411411

412-
if (worldPt) attributes[PlotAttribute.FIXED_TARGET]= worldPt;
413-
if (circle) attributes[PlotAttribute.REQUESTED_SIZE]= circle.radius; // says radius but really size
412+
if (worldPt) {
413+
const cc= CysConverter.make(plot);
414+
if (cc.pointInPlot(worldPt)) {
415+
attributes[PlotAttribute.FIXED_TARGET]= worldPt;
416+
if (circle) attributes[PlotAttribute.REQUESTED_SIZE]= circle.radius; // says radius but really size
417+
}
418+
}
414419
if (req.getUniqueKey()) attributes[PlotAttribute.UNIQUE_KEY]= req.getUniqueKey();
415420
if (req.isMinimalReadout()) attributes[PlotAttribute.MINIMAL_READOUT]=true;
416421

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55

66
import React from 'react';
7-
import {dispatchShowDialog} from '../../core/ComponentCntlr.js';
7+
import {dispatchShowDialog, dispatchHideDialog} from '../../core/ComponentCntlr.js';
88
import sCompare from 'react-addons-shallow-compare';
9-
import {getActivePlotView} from '../PlotViewUtil.js';
9+
import {getActivePlotView, getAllDrawLayersForPlot} from '../PlotViewUtil.js';
1010
import DialogRootContainer from '../../ui/DialogRootContainer.jsx';
1111
import {PopupPanel} from '../../ui/PopupPanel.jsx';
1212
import {getDlAry} from '../DrawLayerCntlr.js';
@@ -39,6 +39,9 @@ export function showDrawingLayerPopup() {
3939
dispatchShowDialog(DRAW_LAYER_POPUP);
4040
}
4141

42+
export function hideDrawingLayerPopup() {
43+
dispatchHideDialog(DRAW_LAYER_POPUP);
44+
}
4245

4346

4447
class DrawLayerPanel extends React.Component {
@@ -65,7 +68,14 @@ class DrawLayerPanel extends React.Component {
6568
var activePv= getActivePlotView(visRoot());
6669

6770
if (activePv!==state.activePv || getDlAry()!==state.dlAry) {
68-
this.setState({dlAry:getDlAry(),activePv});
71+
const dlAry= getDlAry();
72+
var layers= getAllDrawLayersForPlot(dlAry,activePv.plotId);
73+
if (layers.length) {
74+
this.setState({dlAry,activePv});
75+
}
76+
else {
77+
setTimeout(() => hideDrawingLayerPopup(),0)
78+
}
6979
}
7080
}
7181

0 commit comments

Comments
 (0)