Skip to content

Commit 3bb0d02

Browse files
committed
firefly-793: cleanup
1 parent 9cf7bd5 commit 3bb0d02

File tree

4 files changed

+14
-64
lines changed

4 files changed

+14
-64
lines changed

src/firefly/js/visualize/PlotViewUtil.js

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,45 +1042,6 @@ export const pvEqualExScroll= memorizeLastCall((pv1,pv2) => {
10421042
return result;
10431043
},4);
10441044

1045-
export const pvEqualForRender= (pv1,pv2) => {
1046-
if (pv1 === pv2) return true;
1047-
let result= true;
1048-
if (!pv1 || !pv2 ||
1049-
pv1.plotId !== pv2.plotId ||
1050-
pv1.primeIdx!==pv2.primeIdx ||
1051-
pv1.serverCall!==pv2.serverCall ||
1052-
pv1.visible!==pv2.visible ||
1053-
pv1.scrollX!==pv2.scrollX ||
1054-
pv1.scrollY!==pv2.scrollY ||
1055-
pv1.rotation!==pv2.rotation ||
1056-
pv1.flipY!==pv2.flipY ||
1057-
pv1.flipX!==pv2.flipX ||
1058-
!shallowequal(pv1.viewDim,pv2.viewDim) ||
1059-
!shallowequal(pv1.affTrans,pv2.affTrans) ||
1060-
pv1.plottingStatusMsg !== pv2.plottingStatusMsg) {
1061-
result= false;
1062-
}
1063-
if (result && pv1.plots !== pv2.plots) {
1064-
const p1 = primePlot(pv1);
1065-
const p2 = primePlot(pv2);
1066-
if (p1 !== p2) {
1067-
if (p1.plotImageId !== p2.plotImageId || //
1068-
isHiPS(p1) !== isHiPS(p2) ||
1069-
p1.attributes !== p2.attributes ||
1070-
p1.zoomFactor !== p2.zoomFactor ||
1071-
p1.imageCoordSys !== p2.imageCoordSys ||
1072-
p1.dataRequested!==p2.dataRequested ||
1073-
p1.blankColor!==p2.blankColor ||
1074-
p1.dataWidth!==p2.dataWidth ||
1075-
p1.dataHeight!==p2.dataHeight ||
1076-
!shallowequal(p1.screenSize,p2.screenSize) ||
1077-
p1.rawData!==p2.rawData ||
1078-
p1.plotState !== p2.plotState) result= false;
1079-
}
1080-
}
1081-
if (result && !shallowequal(pv1.overlayPlotViews, pv2.overlayPlotViews)) result= false;
1082-
return result;
1083-
};
10841045

10851046

10861047
//===============================================================

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
import React, {Component} from 'react';
66
import PropTypes from 'prop-types';
7-
import {pick} from 'lodash';
87
import {Drawer} from './Drawer.js';
9-
import shallowequal from 'shallowequal';
108
import {makeDrawingDef} from './DrawingDef.js';
119
import {CANVAS_DL_ID_START} from '../PlotViewUtil.js';
1210

@@ -90,7 +88,6 @@ export function makeDummyDrawLayer(drawData) {
9088
};
9189
}
9290

93-
const pickList= ['drawData','drawingDef', 'plotIdAry', 'visiblePlotIdAry'];
9491

9592
class CanvasWrapper extends Component {
9693

@@ -121,14 +118,8 @@ class CanvasWrapper extends Component {
121118
updateDrawLayer(props,force=false) {
122119
const {plot,drawLayer,width,height,getDrawLayer}= props;
123120
let dl= getDrawLayer ? getDrawLayer() : drawLayer;
124-
if (!force &&
125-
Math.floor(width)===this.lastWidth && Math.floor(height)===this.lastHeight &&
126-
shallowequal(pick(dl,pickList),pick(this.lastDrawLayer,pickList))) {
127-
return;
128-
}
121+
if (!force && dl===this.lastDrawLayer) return;
129122
this.lastDrawLayer= dl;
130-
this.lastWidth= Math.floor(width);
131-
this.lastHeight= Math.floor(height);
132123
if (Array.isArray(dl)) dl= makeDummyDrawLayer(dl);
133124

134125
window.requestAnimationFrame(() => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {dlRoot} from '../DrawLayerCntlr.js';
1010
import {useStoreConnector} from 'firefly/ui/SimpleComponent.jsx';
1111

1212

13-
const isVisible= (drawLayer,plotId) => drawLayer.visiblePlotIdAry.includes(plotId);
13+
const isVisible= (drawLayer,plotId) => drawLayer?.visiblePlotIdAry.includes(plotId);
1414

1515
function findDrawLayerInStore(prevDrawLayer, drawLayerId) {
1616
if (!drawLayerId) return undefined;

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
33
*/
44

5-
import React, {memo, useEffect, useRef} from 'react';
5+
import React, {memo, useState, useEffect, useRef} from 'react';
66
import PropTypes from 'prop-types';
77
import {omit} from 'lodash';
88
import shallowequal from 'shallowequal';
9-
import {getPlotViewById, getAllDrawLayersForPlot, pvEqualForRender} from '../PlotViewUtil.js';
9+
import {getPlotViewById,getAllDrawLayersForPlot} from '../PlotViewUtil.js';
1010
import {ImageViewerView} from './ImageViewerDecorate.jsx';
1111
import {visRoot, ExpandType} from '../ImagePlotCntlr.js';
1212
import {extensionRoot} from '../../core/ExternalAccessCntlr.js';
@@ -17,7 +17,7 @@ import {useStoreConnector} from '../../ui/SimpleComponent';
1717
import {dlRoot} from '../DrawLayerCntlr';
1818

1919

20-
const visRootOmitList= ['plotViewAry','activePlotId', 'processedTiles', 'plotRequestDefaults'];
20+
const omitList= ['plotViewAry','activePlotId'];
2121

2222
function hasVisRootChanged(plotId,newVisRoot,oldVisRoot) {
2323
if (newVisRoot===oldVisRoot) return false;
@@ -26,16 +26,14 @@ function hasVisRootChanged(plotId,newVisRoot,oldVisRoot) {
2626
(newVisRoot.activePlotId===plotId || oldVisRoot.activePlotId===plotId)) {
2727
return true;
2828
}
29-
30-
if (!pvEqualForRender(getPlotViewById(oldVisRoot,plotId),getPlotViewById(newVisRoot,plotId))) return true;
31-
return !shallowequal(omit(newVisRoot,visRootOmitList), omit(oldVisRoot,visRootOmitList)); // compare certain keys in visRoot
29+
if (getPlotViewById(newVisRoot,plotId)!==getPlotViewById(oldVisRoot,plotId)) return true;
30+
return !shallowequal(omit(newVisRoot,omitList), omit(oldVisRoot,omitList)); // compare certain keys in visRoot
3231
}
3332

3433
function hasStateChanged(plotId, newState,oldState) {
3534
if (!oldState) return true;
3635
if (newState===oldState) return false;
37-
if (newState?.plotView?.localZoomStart) return false;
38-
// if (!shallowequal(newState.drawLayersAry,oldState.drawLayersAry)) return true;
36+
if (!shallowequal(newState.drawLayersAry,oldState.drawLayersAry)) return true;
3937
if (newState.extRoot!==oldState.extRoot || newState.taskCount!==oldState.taskCount) return true;
4038
return hasVisRootChanged(plotId,newState.vr,oldState.vr);
4139
}
@@ -65,29 +63,29 @@ const TEN_SECONDS= 10000;
6563

6664
export const ImageViewer= memo( ({showWhenExpanded=false, plotId, handleInlineTools=true, inlineTitle, aboveTitle}) => {
6765

68-
const {current:mouseRef} = useRef({mousePlotId:undefined});
66+
const [mousePlotId, setMousePlotId] = useState(lastMouseCtx().plotId);
6967
const [{plotView,vr,drawLayersAry,taskCount}] = useStoreConnector( (oldState) => getStoreState(plotId,oldState) );
7068
const {current:timeoutRef} = useRef({timeId:undefined});
7169

7270
useEffect(() => {
7371
let alive= true;
7472
const removeListener= addImageMouseListener((mState) => {
75-
mouseRef.mousePlotId= mState.plotId;
73+
setMousePlotId(mState.plotId);
7674
timeoutRef.timeId && clearTimeout(timeoutRef.timeId);
7775
timeoutRef.timeId= undefined;
78-
if (mState.mouseState!==MouseState.EXIT || mouseRef.mousePlotId!==plotId) return;
76+
if (mState.mouseState!==MouseState.EXIT || mousePlotId!==plotId) return;
7977
timeoutRef.timeId= setTimeout(
8078
() => {
8179
timeoutRef.timeId= undefined;
82-
if (alive && lastMouseCtx().plotId===plotId) mouseRef.mousePlotId= undefined;
80+
if (alive && lastMouseCtx().plotId===plotId) setMousePlotId(undefined);
8381
}, TEN_SECONDS); // 10 seconds
8482
});
8583
return () => {
8684
alive= false;
8785
timeoutRef.timeId && clearTimeout(timeoutRef.timeId);
8886
removeListener();
8987
};
90-
}, [plotId]);
88+
}, [mousePlotId, plotId]);
9189

9290

9391
if (!showWhenExpanded && vr.expandedMode!==ExpandType.COLLAPSE) return false;
@@ -97,7 +95,7 @@ export const ImageViewer= memo( ({showWhenExpanded=false, plotId, handleInlineTo
9795
<ImageViewerView plotView={plotView}
9896
drawLayersAry={drawLayersAry}
9997
visRoot={vr}
100-
mousePlotId={mouseRef.mousePlotId}
98+
mousePlotId={mousePlotId}
10199
handleInlineTools={handleInlineTools}
102100
inlineTitle={inlineTitle}
103101
aboveTitle={aboveTitle}

0 commit comments

Comments
 (0)