@@ -28,11 +28,11 @@ class FootprintToolUI extends React.Component {
28
28
constructor ( props ) {
29
29
super ( props ) ;
30
30
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 ;
34
33
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' , { } ) ;
36
36
const plot = primePlot ( visRoot ( ) , this . props . pv . plotId ) ;
37
37
38
38
this . csys = CsysConverter . make ( plot ) ;
@@ -43,7 +43,10 @@ class FootprintToolUI extends React.Component {
43
43
this . changeFootprintAngle = this . changeFootprintAngle . bind ( this ) ;
44
44
}
45
45
46
- shouldComponentUpdate ( np , ns ) { return sCompare ( this , np , ns ) ; }
46
+ shouldComponentUpdate ( np , ns ) {
47
+
48
+ return sCompare ( this , np , ns ) ;
49
+ }
47
50
48
51
componentWillUnmount ( ) {
49
52
this . iAmMounted = false ;
@@ -59,17 +62,31 @@ class FootprintToolUI extends React.Component {
59
62
var dl = getDrawLayerById ( flux . getState ( ) [ DRAWING_LAYER_KEY ] , this . props . drawLayer . drawLayerId ) ;
60
63
61
64
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
+ }
73
90
}
74
91
}
75
92
}
@@ -79,23 +96,26 @@ class FootprintToolUI extends React.Component {
79
96
80
97
if ( isNil ( fpText ) || ! fpText ) {
81
98
var dl = getDrawLayerById ( flux . getState ( ) [ DRAWING_LAYER_KEY ] , this . props . drawLayer . drawLayerId ) ;
82
- fpText = get ( dl , '' ) ;
99
+
100
+ fpText = '' ;
83
101
this . props . drawLayer . title = get ( dl , 'defaultTitle' ) ;
84
102
} else {
85
103
this . props . drawLayer . title = fpText ;
86
104
}
87
105
this . setState ( { fpText} ) ;
88
106
89
107
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 ) ;
91
110
}
92
111
93
112
changeFootprintTextLocation ( ev ) {
94
113
var fpTextLoc = get ( ev , 'target.value' ) ;
95
114
96
115
this . setState ( { fpTextLoc} ) ;
97
116
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 ) ;
99
119
}
100
120
101
121
changeFootprintAngle ( ev ) {
@@ -108,7 +128,8 @@ class FootprintToolUI extends React.Component {
108
128
}
109
129
this . setState ( { isValidAngle, angleDeg} ) ;
110
130
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 ) ;
112
133
}
113
134
}
114
135
@@ -127,48 +148,51 @@ class FootprintToolUI extends React.Component {
127
148
var { isValidAngle, angleDeg, fpText, fpTextLoc} = this . state ;
128
149
129
150
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 } } >
164
153
< div > Center:</ div >
165
154
< div style = { tStyle } >
166
155
{ convertWorldLonToString ( this . state . currentPt , this . csys ) + ', ' +
167
- convertWorldLatToString ( this . state . currentPt , this . csys ) }
156
+ convertWorldLatToString ( this . state . currentPt , this . csys ) }
168
157
{ convertWorldToString ( this . state . currentPt , this . csys ) }
169
158
</ div >
170
159
</ div >
171
160
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 >
172
196
</ div >
173
197
) ;
174
198
}
0 commit comments