Skip to content

IRSA-613: fixed: WCS match not working right for image that are very far apart #428

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 2 commits into from
Jul 31, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions src/firefly/js/visualize/CsysConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export class CysConverter {

getDevicePtCoordsOptimize(wpt, retPt) {
const success= this.getScreenCoordsOptimize(wpt,retPt);
if (!success) return false;
if (!success || !this.affTrans) return false;
const {x,y}= Matrix.from(this.affTrans).applyToPoint(retPt.x,retPt.y);
retPt.x= x;
retPt.y= y;
Expand All @@ -371,7 +371,7 @@ export class CysConverter {
* @return {DevicePt}
*/
makeDevicePtFromSp(sp, altTransform) {
if (!sp) return null;
if (!sp || !this.affTrans) return null;
const {x,y}= Matrix.from(altTransform || this.affTrans).applyToPoint(sp.x,sp.y);
return makeDevicePt(x,y);
}
Expand Down Expand Up @@ -421,7 +421,7 @@ export class CysConverter {
}

makeSpFromDevPt(devPt) {
if (!devPt) return null;
if (!devPt || !this.affTrans) return null;
const {x,y}= Matrix.from(this.affTrans).inverse().applyToPoint(devPt.x,devPt.y);
return makeScreenPt(x,y);
}
Expand Down
11 changes: 8 additions & 3 deletions src/firefly/js/visualize/ImageViewerLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import React, {Component, PureComponent} from 'react';
import PropTypes from 'prop-types';
import {xor,isEmpty,get, isString, isFunction, throttle} from 'lodash';
import {xor,isNil, isEmpty,get, isString, isFunction, throttle} from 'lodash';
import {ImageRender} from './iv/ImageRender.jsx';
import {EventLayer} from './iv/EventLayer.jsx';
import {ImageViewerStatus} from './iv/ImageViewerStatus.jsx';
Expand Down Expand Up @@ -273,6 +273,7 @@ function isImageOnScreen(plotView) {
const {viewDim}= plotView;
const plot= primePlot(plotView);

if (isNil(plotView.scrollX) || isNil(plotView.scrollY)) return false;
const cc= CysConverter.make(plot);
const {screenSize}= plot;
const devAsScreenAry= [
Expand Down Expand Up @@ -486,11 +487,15 @@ class DrawingLayers extends Component {

shouldComponentUpdate(np) {
const p= this.props;
return np.plot!==p.plot || !isEmpty(xor(np.drawLayersIdAry,p.drawLayersIdAry));
return np.plot!==p.plot || !isEmpty(xor(np.drawLayersIdAry,p.drawLayersIdAry)) ||
np.plotView.scrollX!==p.plotView.scrollX || np.plotView.scrollY!==p.plotView.scrollY;
}

render() {
const {plotView:pv, plot, drawLayersIdAry:dlIdAry}= this.props;
const {scrollX, scrollY}= pv;
const draw= !isNil(scrollX) && !isNil(scrollY);
if (!draw) return null;
let drawingAry= null;
const {width,height}= pv.viewDim;
if (dlIdAry) {
Expand Down
3 changes: 2 additions & 1 deletion src/firefly/js/visualize/PlotTransformUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
*/

import {get} from 'lodash';
import {get, isNil} from 'lodash';
import {Matrix} from 'transformation-matrix-js';
import {primePlot} from './PlotViewUtil.js';
import {clone, updateSet} from '../util/WebUtil.js';
Expand Down Expand Up @@ -57,6 +57,7 @@ export function updateTransform(pv) {
* @return {Matrix}
*/
export function makeTransform(offsetX,offsetY,scrollX,scrollY, rotation, flipX, flipY, viewDim) {
if (isNil(scrollX) || isNil(scrollY)) return undefined;
const left= offsetX-scrollX;
const top= offsetY-scrollY;
const {width:w, height:h}= viewDim;
Expand Down
9 changes: 6 additions & 3 deletions src/firefly/js/visualize/iv/CanvasTileDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

import CsysConverter from '../CsysConverter.js';
import {isNil} from 'lodash';
import {makeDevicePt} from '../Point.js';
import {createImageUrl,isTileVisible} from './TileDrawHelper.jsx';
import {makeTransform} from '../PlotTransformUtils.js';
Expand Down Expand Up @@ -222,9 +223,11 @@ function renderToScreen(plotView, targetCanvas, offscreenCanvas, opacity, offset
const {scrollX, scrollY, flipX,flipY, viewDim, rotation}= plotView;
if (flipY) offsetX*=-1;

const affTrans= makeTransform(offsetX,offsetY, scrollX, scrollY, rotation, flipX, flipY, viewDim);
ctx.setTransform(affTrans.a, affTrans.b, affTrans.c, affTrans.d, affTrans.e, affTrans.f);
ctx.drawImage(offscreenCanvas, 0,0);
if (!isNil(plotView.scrollX) && !isNil(plotView.scrollY)) {
const affTrans= makeTransform(offsetX,offsetY, scrollX, scrollY, rotation, flipX, flipY, viewDim);
ctx.setTransform(affTrans.a, affTrans.b, affTrans.c, affTrans.d, affTrans.e, affTrans.f);
ctx.drawImage(offscreenCanvas, 0,0);
}
ctx.restore();
});
}
Expand Down
16 changes: 11 additions & 5 deletions src/firefly/js/visualize/reducer/PlotView.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ export function replacePlots(pv, plotAry, overlayPlotViews, expandedMode, newPlo
* @return {PlotView} new copy of plotView
*/
export function updatePlotViewScrollXY(plotView,newScrollPt) {
if (!plotView || !newScrollPt) return plotView;
if (!plotView) return plotView;
if (!newScrollPt) return Object.assign({},plotView, {scrollX:undefined, scrollY:undefined});

const plot= primePlot(plotView);
if (!plot) return plotView;
Expand Down Expand Up @@ -532,13 +533,18 @@ export function findScrollPtToCenterImagePt(plotView, ipt) {
*/
export function findScrollPtToPlaceOnDevPt(pv, ipt, targetDevPtPos) {
const plot= primePlot(pv);
const point= CCUtil.getScreenCoords(plot, ipt);

const target= CCUtil.getScreenCoords(plot, targetDevPtPos);
const altAffTrans= makeTransform(0,0, 0, 0, pv.rotation, pv.flipX, pv.flipY, pv.viewDim);
const cc= CysConverter.make(plot,altAffTrans);

const point= cc.getScreenCoords(ipt);
if (!point) return null;

const target= cc.getScreenCoords(targetDevPtPos);
if (!target) return null;

const x= point.x - target.x;
const y= point.y - target.y;


return makeScreenPt(pv.flipY ? pv.scrollX-x : pv.scrollX+x,pv.flipX ? pv.scrollY-y : pv.scrollY+y);
return makeScreenPt(pv.flipY ? -x : x,pv.flipX ? -y : y);
}