Skip to content

DM-7029: fixed some api bugs #126

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 3 commits into from
Jul 29, 2016
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions src/firefly/js/api/ApiUtilImage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export {RangeValues} from '../visualize/RangeValues.js';
export {WPConst, WebPlotRequest, findInvalidWPRKeys, confirmPlotRequest} from '../visualize/WebPlotRequest.js';
export {RequestType} from '../visualize/RequestType';
export {ExpandType, dispatchApiToolsView} from '../visualize/ImagePlotCntlr.js';
export {CsysConverter} from '../visualize/CsysConverter.js';
export {CCUtil} from '../visualize/CsysConverter.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To use CCUtil, we need to add the following exports:
export {primePlot} from '../visualize/PlotViewUtil.js';
export {visRoot} from '../visualize/ImagePlotCntlr.js';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I will do that too.

export {watchCoverage} from '../visualize/saga/CoverageWatcher.js';
import {watchImageMetaData} from '../visualize/saga/ImageMetaDataWatcher.js';

Expand Down
4 changes: 2 additions & 2 deletions src/firefly/js/drawingLayers/SelectArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function creator() {
DrawLayerCntlr.SELECT_AREA_MOVE,
DrawLayerCntlr.SELECT_AREA_END,
DrawLayerCntlr.SELECT_MOUSE_LOC];

var exclusiveDef= { exclusiveOnDown: true, type : 'anywhere' };


Expand Down Expand Up @@ -259,7 +259,7 @@ function drag(drawLayer,action) {
var plot= primePlot(visRoot(),plotId);
if (!plot) return;
var drawSel= makeSelectObj(drawLayer.firstPt, imagePt, CsysConverter.make(plot));
var exclusiveDef= { exclusiveOnDown: true, type : 'vertexOnly' };
var exclusiveDef= { exclusiveOnDown: true, type : 'vertexThenAnywhere' };
return {currentPt:imagePt,
drawData:{data:drawSel},
exclusiveDef,
Expand Down
19 changes: 15 additions & 4 deletions src/firefly/js/visualize/PlotImageTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import CsysConverter from './CsysConverter.js';
import {dispatchActiveTarget, getActiveTarget} from '../core/AppDataCntlr.js';
import VisUtils from './VisUtil.js';
import {PlotState} from './PlotState.js';
import {makeImagePt} from './Point.js';
import Point, {makeImagePt} from './Point.js';
import {WPConst, DEFAULT_THUMBNAIL_SIZE} from './WebPlotRequest.js';
import {Band} from './Band.js';
import {PlotPref} from './PlotPref.js';
Expand Down Expand Up @@ -230,7 +230,7 @@ export function processPlotImageSuccessResponse(dispatcher, payload, result) {

pvNewPlotInfoAry
.forEach((info) => info.plotAry
.forEach( (p) => addDrawLayers(p.plotState.getWebPlotRequest(), p.plotId) ));
.forEach( (p) => addDrawLayers(p.plotState.getWebPlotRequest(), p) ));



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


function addDrawLayers(request, plotId ) {
function addDrawLayers(request, plot ) {
const {plotId}= plot;
request.getOverlayIds().forEach((drawLayerTypeId)=> {
const dl = getDrawLayerByType(dlRoot(), drawLayerTypeId);
if (dl) DrawLayerCntlr.dispatchAttachLayerToPlot(dl.drawLayerId, plotId);
if (dl) {
if (dl.drawLayerTypeId===ActiveTarget.TYPE_ID) {
const pt= plot.attributes[PlotAttribute.FIXED_TARGET];
if (pt && pt.type===Point.W_PT) {
DrawLayerCntlr.dispatchAttachLayerToPlot(dl.drawLayerId, plotId);
}
}
else {
DrawLayerCntlr.dispatchAttachLayerToPlot(dl.drawLayerId, plotId);
}
}
});

if (request.getGridOn()!==GridOnStatus.FALSE) {
Expand Down
6 changes: 3 additions & 3 deletions src/firefly/js/visualize/draw/DrawerComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
*/

import React from 'react';
import difference from 'lodash/difference';
import isEqual from 'lodash/isEqual';
import {xor,isEqual} from 'lodash';
import sCompare from 'react-addons-shallow-compare';
import CanvasWrapper from './CanvasWrapper.jsx';
import TextDrawer from './TextDrawer.jsx';
Expand Down Expand Up @@ -80,7 +79,8 @@ export class DrawerComponent extends React.Component {
textUpdateCallback(textDrawAry) {
var {textDrawAry:old}= this.state;
//if ((!textDrawAry && !old) || !textDrawAry.length && !old.length) return;
if (!difference(textDrawAry,old).length) return;
// if (!difference(textDrawAry,old).length && !difference(old,textDrawAry).length) return;
if (!xor(textDrawAry,old).length) return;

var doUpdate=
old.length!=textDrawAry.length ||
Expand Down
19 changes: 12 additions & 7 deletions src/firefly/js/visualize/iv/EventLayer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ export var EventLayer= React.createClass(
var {x:viewPortX,y:viewPortY} = viewPort;
var {screenX, screenY, pageX:x, pageY:y}= nativeEv;
var e= ReactDOM.findDOMNode(this);
var compOffX= x-getAbsoluteLeft(e)+window.scrollX-1;
var compOffY= y-getAbsoluteTop(e)+window.scrollY-1;
// var compOffX= x-getAbsoluteLeft(e)+window.scrollX-1;
// var compOffY= y-getAbsoluteTop(e)+window.scrollY-1;
var compOffX= x-getAbsoluteLeft(e);
var compOffY= y-getAbsoluteTop(e);
spt= makeScreenPt( viewPortX+compOffX, viewPortY+compOffY);
this.props.eventCallback(plotId,mouseState,spt,screenX,screenY);
},
Expand Down Expand Up @@ -96,6 +98,14 @@ export var EventLayer= React.createClass(

},


onMouseMove(ev) {
if (!this.mouseDown) {
var {viewPort,plotId}= this.props;
this.fireEvent(ev,plotId,viewPort,this.mouseDown?MouseState.DRAG_COMPONENT : MouseState.MOVE);
}
},

onDocumentMouseMove(nativeEv) {
if (this.mouseDown) {
var {viewPort,plotId}= this.props;
Expand Down Expand Up @@ -124,11 +134,6 @@ export var EventLayer= React.createClass(
},


onMouseMove(ev) {
var {viewPort,plotId}= this.props;
this.fireEvent(ev,plotId,viewPort,this.mouseDown?MouseState.DRAG_COMPONENT : MouseState.MOVE);
},


onTouchCancel(ev) {
this.mouseDown= false;
Expand Down
6 changes: 3 additions & 3 deletions src/firefly/js/visualize/iv/ImageViewerLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ function findMouseOwner(dlList, plot, screenPt) {
const y= screenPt.y- dist;
const w= dist*2;
const h= dist*2;
return vertexDef.points.find( (p) => {
const spt= cc.getScreenCoords(p);
return contains(x,y,w,h,spt.x,spt.y);
return vertexDef.points.find( (pt) => {
const spt= cc.getScreenCoords(pt);
return spt && contains(x,y,w,h,spt.x,spt.y);
} );
});

Expand Down
11 changes: 8 additions & 3 deletions src/firefly/js/visualize/reducer/PlotView.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,19 @@ function getNewAttributes(plot) {
worldPt= circle.center;
}
else if (getActiveTarget()) {
worldPt= getActiveTarget();
worldPt= getActiveTarget().worldPt;
}
else {
worldPt= VisUtil.getCenterPtOfPlot(plot);
}

if (worldPt) attributes[PlotAttribute.FIXED_TARGET]= worldPt;
if (circle) attributes[PlotAttribute.REQUESTED_SIZE]= circle.radius; // says radius but really size
if (worldPt) {
const cc= CysConverter.make(plot);
if (cc.pointInPlot(worldPt)) {
attributes[PlotAttribute.FIXED_TARGET]= worldPt;
if (circle) attributes[PlotAttribute.REQUESTED_SIZE]= circle.radius; // says radius but really size
}
}
if (req.getUniqueKey()) attributes[PlotAttribute.UNIQUE_KEY]= req.getUniqueKey();
if (req.isMinimalReadout()) attributes[PlotAttribute.MINIMAL_READOUT]=true;

Expand Down
16 changes: 13 additions & 3 deletions src/firefly/js/visualize/ui/DrawLayerPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@


import React from 'react';
import {dispatchShowDialog} from '../../core/ComponentCntlr.js';
import {dispatchShowDialog, dispatchHideDialog} from '../../core/ComponentCntlr.js';
import sCompare from 'react-addons-shallow-compare';
import {getActivePlotView} from '../PlotViewUtil.js';
import {getActivePlotView, getAllDrawLayersForPlot} from '../PlotViewUtil.js';
import DialogRootContainer from '../../ui/DialogRootContainer.jsx';
import {PopupPanel} from '../../ui/PopupPanel.jsx';
import {getDlAry} from '../DrawLayerCntlr.js';
Expand Down Expand Up @@ -39,6 +39,9 @@ export function showDrawingLayerPopup() {
dispatchShowDialog(DRAW_LAYER_POPUP);
}

export function hideDrawingLayerPopup() {
dispatchHideDialog(DRAW_LAYER_POPUP);
}


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

if (activePv!==state.activePv || getDlAry()!==state.dlAry) {
this.setState({dlAry:getDlAry(),activePv});
const dlAry= getDlAry();
var layers= getAllDrawLayersForPlot(dlAry,activePv.plotId);
if (layers.length) {
this.setState({dlAry,activePv});
}
else {
setTimeout(() => hideDrawingLayerPopup(),0)
}
}
}

Expand Down