Skip to content

Commit fbb4944

Browse files
authored
Merge pull request #360 from Caltech-IPAC/DM-10188-FPMarkerHandleOff
DM-10188 Fix drawing related issues on markers and footprints with new rotation scheme
2 parents ff29e4f + 784ea10 commit fbb4944

File tree

8 files changed

+521
-432
lines changed

8 files changed

+521
-432
lines changed

src/firefly/js/drawingLayers/FootprintTool.js

Lines changed: 125 additions & 153 deletions
Large diffs are not rendered by default.

src/firefly/js/drawingLayers/FootprintToolUI.jsx

Lines changed: 79 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ class FootprintToolUI extends React.Component {
2828
constructor(props) {
2929
super(props);
3030

31-
var {angle = 0.0, angleUnit = ANGLE_UNIT.radian,
32-
text = '', textLoc = defaultFootprintTextLoc} = get(this.props.drawLayer, ['drawData', 'data', '0']) || {};
33-
31+
var fpObj = get(this.props.drawLayer, ['drawData', 'data', this.props.pv.plotId], {});
32+
var {angle = 0.0, angleUnit = ANGLE_UNIT.radian, text = '', textLoc = defaultFootprintTextLoc} = fpObj;
3433
var angleDeg = `${formatAngle(convertAngle(angleUnit.key, 'deg', angle))}`;
35-
var {fpInfo, currentPt} = this.props.drawLayer;
34+
var {fpInfo} = this.props.drawLayer;
35+
var {currentPt} = get(fpObj, 'actionInfo', {});
3636
const plot= primePlot(visRoot(),this.props.pv.plotId);
3737

3838
this.csys = CsysConverter.make(plot);
@@ -43,7 +43,10 @@ class FootprintToolUI extends React.Component {
4343
this.changeFootprintAngle = this.changeFootprintAngle.bind(this);
4444
}
4545

46-
shouldComponentUpdate(np, ns) {return sCompare(this, np, ns); }
46+
shouldComponentUpdate(np, ns) {
47+
48+
return sCompare(this, np, ns);
49+
}
4750

4851
componentWillUnmount() {
4952
this.iAmMounted= false;
@@ -59,17 +62,31 @@ class FootprintToolUI extends React.Component {
5962
var dl = getDrawLayerById(flux.getState()[DRAWING_LAYER_KEY], this.props.drawLayer.drawLayerId);
6063

6164
if (dl && this.iAmMounted) {
62-
var {currentPt} = dl;
63-
if (currentPt) {
64-
currentPt = this.csys.getWorldCoords(currentPt);
65-
this.setState({currentPt});
66-
}
67-
68-
if (!get(dl, ['drawData', 'data', '0', 'angleFromUI'], false)) {
69-
var {angle = 0.0, angleUnit = ANGLE_UNIT.radian} = get(dl, ['drawData', 'data', '0']) || {};
70-
71-
angle = convertAngle(angleUnit.key, 'deg', angle);
72-
this.setState({angleDeg: `${formatAngle(angle)}`, isValidAngle: true});
65+
const crtFpObj = get(dl, ['drawData', 'data', this.props.pv.plotId]);
66+
67+
if (crtFpObj) {
68+
var {currentPt} = get(crtFpObj, 'actionInfo', {});
69+
if (currentPt) {
70+
currentPt = this.csys.getWorldCoords(currentPt);
71+
if (currentPt !== this.state.currentPt) {
72+
this.setState({currentPt});
73+
}
74+
}
75+
76+
if (!get(crtFpObj, 'angleFromUI', false)) {
77+
var {angle = 0.0, angleUnit = ANGLE_UNIT.radian} = crtFpObj;
78+
79+
angle = convertAngle(angleUnit.key, 'deg', angle);
80+
this.setState({angleDeg: `${formatAngle(angle)}`, isValidAngle: true});
81+
}
82+
83+
var {text = '', textLoc = defaultFootprintTextLoc} = crtFpObj;
84+
if (text !== this.state.fpText) {
85+
this.setState({fpText: text});
86+
}
87+
if (textLoc.key !== this.state.fpTextLoc) {
88+
this.setState({fpTextLoc: textLoc.key});
89+
}
7390
}
7491
}
7592
}
@@ -79,23 +96,26 @@ class FootprintToolUI extends React.Component {
7996

8097
if (isNil(fpText) || !fpText) {
8198
var dl = getDrawLayerById(flux.getState()[DRAWING_LAYER_KEY], this.props.drawLayer.drawLayerId);
82-
fpText = get(dl, '');
99+
100+
fpText = '';
83101
this.props.drawLayer.title = get(dl, 'defaultTitle');
84102
} else {
85103
this.props.drawLayer.title = fpText;
86104
}
87105
this.setState({fpText});
88106

89107
dispatchModifyCustomField( this.props.drawLayer.drawLayerId,
90-
{fpText, fpTextLoc: TextLocation.get(this.state.fpTextLoc)}, this.props.pv.plotId);
108+
{fpText, fpTextLoc: TextLocation.get(this.state.fpTextLoc), activePlotId: this.props.pv.plotId },
109+
this.props.pv.plotId);
91110
}
92111

93112
changeFootprintTextLocation(ev) {
94113
var fpTextLoc = get(ev, 'target.value');
95114

96115
this.setState({fpTextLoc});
97116
dispatchModifyCustomField( this.props.drawLayer.drawLayerId,
98-
{fpText: this.state.fpText, fpTextLoc: TextLocation.get(fpTextLoc)}, this.props.pv.plotId);
117+
{fpText: this.state.fpText, fpTextLoc: TextLocation.get(fpTextLoc), activePlotId: this.props.pv.plotId },
118+
this.props.pv.plotId);
99119
}
100120

101121
changeFootprintAngle(ev) {
@@ -108,7 +128,8 @@ class FootprintToolUI extends React.Component {
108128
}
109129
this.setState({isValidAngle, angleDeg});
110130
if (isValidAngle) {
111-
dispatchModifyCustomField(this.props.drawLayer.drawLayerId, {angleDeg}, this.props.pv.plotId);
131+
dispatchModifyCustomField(this.props.drawLayer.drawLayerId, {angleDeg, activePlotId: this.props.pv.plotId },
132+
this.props.pv.plotId);
112133
}
113134
}
114135

@@ -127,48 +148,51 @@ class FootprintToolUI extends React.Component {
127148
var {isValidAngle, angleDeg, fpText, fpTextLoc} = this.state;
128149

129150
return (
130-
<div style={{display:'flex', justifyContent:'flex-start', padding:'5px 0 9px 0'}}>
131-
<div style={tStyle}>
132-
<div title={'Add a lable to this footprint'}> Label:<input style={{width: 60}}
133-
type='text'
134-
value={fpText}
135-
onChange={this.changeFootprintText}/>
136-
</div>
137-
<div style={mStyle} title={'Choose a corner'}> Corners:
138-
<select value={fpTextLoc} onChange={ this.changeFootprintTextLocation }>
139-
<option value={TextLocation.REGION_NE.key}> NE </option>
140-
<option value={TextLocation.REGION_NW.key}> NW </option>
141-
<option value={TextLocation.REGION_SE.key}> SE </option>
142-
<option value={TextLocation.REGION_SW.key}> SW </option>
143-
</select>
144-
</div>
145-
</div>
146-
<div style={tStyle}>
147-
<InputFieldView
148-
valid={isValidAngle}
149-
onChange={this.changeFootprintAngle}
150-
value={angleDeg}
151-
message={'invalid angle value'}
152-
label={'Angle:'}
153-
labelWidth={30}
154-
style={{width: 50}}
155-
tooltip={'Enter the angle in degree you want the footprint rotated'}
156-
157-
/>
158-
<div style={mStyle} title={textOnLink}>
159-
<a className='ff-href' style={{textDecoration: 'underline'}}
160-
onClick={()=>addFootprintDrawLayer(this.props.pv, this.state.fpInfo)}>{textOnLink}</a>
161-
</div>
162-
</div>
163-
<div style={{display:'flex', justifyContent: 'flex-start', paddingLeft:10}}>
151+
<div style={{display:'flex', justifyContent:'flex-start', flexDirection: 'column', padding:'5px 0 9px 0'}}>
152+
<div style={{display:'flex', justifyContent: 'flex-start', paddingLeft:10, paddingBottom:8}}>
164153
<div> Center:</div>
165154
<div style={tStyle}>
166155
{convertWorldLonToString(this.state.currentPt, this.csys) + ', ' +
167-
convertWorldLatToString(this.state.currentPt, this.csys)}
156+
convertWorldLatToString(this.state.currentPt, this.csys)}
168157
{convertWorldToString(this.state.currentPt, this.csys)}
169158
</div>
170159
</div>
171160

161+
<div style={{display:'flex', justifyContent:'flex-start'}}>
162+
163+
<div style={tStyle}>
164+
<div title={'Add a lable to this footprint'}> Label:<input style={{width: 60}}
165+
type='text'
166+
value={fpText}
167+
onChange={this.changeFootprintText}/>
168+
</div>
169+
<div style={mStyle} title={'Choose a corner'}> Corners:
170+
<select value={fpTextLoc} onChange={ this.changeFootprintTextLocation }>
171+
<option value={TextLocation.REGION_NE.key}> NE </option>
172+
<option value={TextLocation.REGION_NW.key}> NW </option>
173+
<option value={TextLocation.REGION_SE.key}> SE </option>
174+
<option value={TextLocation.REGION_SW.key}> SW </option>
175+
</select>
176+
</div>
177+
</div>
178+
<div style={tStyle}>
179+
<InputFieldView
180+
valid={isValidAngle}
181+
onChange={this.changeFootprintAngle}
182+
value={angleDeg}
183+
message={'invalid angle value'}
184+
label={'Angle:'}
185+
labelWidth={30}
186+
style={{width: 50}}
187+
tooltip={'Enter the angle in degree you want the footprint rotated'}
188+
189+
/>
190+
<div style={mStyle} title={textOnLink}>
191+
<a className='ff-href' style={{textDecoration: 'underline'}}
192+
onClick={()=>addFootprintDrawLayer(this.props.pv, this.state.fpInfo)}>{textOnLink}</a>
193+
</div>
194+
</div>
195+
</div>
172196
</div>
173197
);
174198
}

0 commit comments

Comments
 (0)