1
- /* eslint-disable no-mixed-operators */
1
+ /* eslint-disable no-mixed-operators, prefer-object-spread, react/function-component-definition */
2
2
import React from 'react' ;
3
3
import { connect } from 'react-redux' ;
4
- import { bindActionCreators } from 'redux' ;
4
+ import { bindActionCreators , compose } from 'redux' ;
5
5
import PropTypes from 'prop-types' ;
6
6
import classNames from 'classnames' ;
7
+ import withStyles from '@mui/styles/withStyles' ;
7
8
import {
8
9
Select , MenuItem , FormControl , InputLabel ,
10
+ Tooltip ,
9
11
} from '@mui/material' ;
12
+ import ZoomInOutlinedIcon from '@mui/icons-material/ZoomInOutlined' ;
13
+ import FindReplaceOutlinedIcon from '@mui/icons-material/FindReplaceOutlined' ;
14
+ import { MuButton , commonStyle , focusStyle } from '../cmd_bar/common' ;
10
15
11
16
import {
12
17
Topic2Seed , ToThresEndPts ,
13
18
} from '../../helpers/chem' ;
14
19
import { resetAll } from '../../actions/manager' ;
15
- import { selectUiSweep , scrollUiWheel , clickUiTarget } from '../../actions/ui' ;
20
+ import {
21
+ selectUiSweep , scrollUiWheel , clickUiTarget , setUiSweepType ,
22
+ } from '../../actions/ui' ;
16
23
import { selectWavelength , changeTic } from '../../actions/hplcms' ;
17
24
import { selectCurve } from '../../actions/curve' ;
18
25
import RectFocus from './rect_focus' ;
@@ -25,12 +32,72 @@ import {
25
32
} from '../common/draw' ;
26
33
import { LIST_UI_SWEEP_TYPE , LIST_NON_BRUSH_TYPES } from '../../constants/list_ui' ;
27
34
import { LIST_ROOT_SVG_GRAPH , LIST_BRUSH_SVG_GRAPH } from '../../constants/list_graph' ;
28
- import Zoom from '../cmd_bar/02_zoom' ;
35
+ // import Zoom from '../cmd_bar/02_zoom';
29
36
import PeakGroup from '../cmd_bar/08_peak_group' ;
30
37
31
38
const W = Math . round ( window . innerWidth * 0.90 * 9 / 12 ) ; // ROI
32
39
const H = Math . round ( window . innerHeight * 0.90 * 0.85 / 3 ) ; // ROI
33
40
41
+ const styles = ( ) => (
42
+ Object . assign (
43
+ { } ,
44
+ commonStyle ,
45
+ )
46
+ ) ;
47
+
48
+ const zoomView = ( classes , graphIndex , uiSt , zoomInAct ) => {
49
+ const onSweepZoomIn = ( ) => {
50
+ const payload = {
51
+ graphIndex,
52
+ sweepType : LIST_UI_SWEEP_TYPE . ZOOMIN ,
53
+ } ;
54
+ zoomInAct ( payload ) ;
55
+ } ;
56
+
57
+ const onSweepZoomReset = ( ) => {
58
+ const payload = {
59
+ graphIndex,
60
+ sweepType : LIST_UI_SWEEP_TYPE . ZOOMRESET ,
61
+ } ;
62
+ zoomInAct ( payload ) ;
63
+ } ;
64
+
65
+ const { zoom } = uiSt ;
66
+ const { sweepTypes } = zoom ;
67
+
68
+ const isZoomFocus = sweepTypes [ graphIndex ] === LIST_UI_SWEEP_TYPE . ZOOMIN ;
69
+
70
+ return (
71
+ < span className = { classes . group } data-testid = "Zoom" >
72
+ < Tooltip title = { < span className = "txt-sv-tp" > Zoom In</ span > } >
73
+ < MuButton
74
+ className = {
75
+ classNames (
76
+ focusStyle ( isZoomFocus , classes ) ,
77
+ 'btn-sv-bar-zoomin' ,
78
+ )
79
+ }
80
+ onClick = { onSweepZoomIn }
81
+ >
82
+ < ZoomInOutlinedIcon className = { classNames ( classes . icon , classes . iconWp ) } />
83
+ </ MuButton >
84
+ </ Tooltip >
85
+ < Tooltip title = { < span className = "txt-sv-tp" > Reset Zoom</ span > } >
86
+ < MuButton
87
+ className = {
88
+ classNames (
89
+ 'btn-sv-bar-zoomreset' ,
90
+ )
91
+ }
92
+ onClick = { onSweepZoomReset }
93
+ >
94
+ < FindReplaceOutlinedIcon className = { classes . icon } />
95
+ </ MuButton >
96
+ </ Tooltip >
97
+ </ span >
98
+ ) ;
99
+ } ;
100
+
34
101
const waveLengthSelect = ( classes , hplcMsSt , updateWaveLengthAct ) => {
35
102
const { uvvis } = hplcMsSt ;
36
103
const { listWaveLength, selectedWaveLength } = uvvis ;
@@ -128,15 +195,18 @@ class ViewerLineRect extends React.Component {
128
195
const {
129
196
entities, curveSt, seed, cLabel, xLabel, yLabel, feature,
130
197
tTrEndPts, layoutSt,
131
- sweepExtentSt , isUiAddIntgSt, isUiNoBrushSt,
132
- isHidden, sweepExtentSubViewSt ,
133
- resetAllAct,
198
+ isUiAddIntgSt, isUiNoBrushSt,
199
+ isHidden,
200
+ resetAllAct, uiSt ,
134
201
} = this . props ;
135
202
drawDestroy ( this . rootKlassMulti ) ;
136
203
drawDestroy ( this . rootKlassLine ) ;
137
204
drawDestroy ( this . rootKlassRect ) ;
138
205
resetAllAct ( feature ) ;
139
206
207
+ const { zoom } = uiSt ;
208
+ const { sweepExtent } = zoom ;
209
+
140
210
const uvvisViewFeature = this . extractUvvisView ( ) ;
141
211
const { data } = uvvisViewFeature ;
142
212
const currentData = data [ 0 ] ;
@@ -151,7 +221,7 @@ class ViewerLineRect extends React.Component {
151
221
filterPeak : [ ] ,
152
222
tTrEndPts,
153
223
isUiNoBrushSt : true ,
154
- sweepExtentSt : sweepExtentSubViewSt ,
224
+ sweepExtentSt : sweepExtent [ 0 ] ,
155
225
} ) ;
156
226
drawLabel ( this . rootKlassLine , null , 'M/Z' , 'Intensity' ) ;
157
227
drawDisplay ( this . rootKlassLine , false ) ;
@@ -165,7 +235,7 @@ class ViewerLineRect extends React.Component {
165
235
filterSeed,
166
236
tTrEndPts,
167
237
layoutSt,
168
- sweepExtentSt,
238
+ sweepExtentSt : sweepExtent [ 1 ] ,
169
239
isUiAddIntgSt,
170
240
isUiNoBrushSt,
171
241
} ) ;
@@ -178,7 +248,7 @@ class ViewerLineRect extends React.Component {
178
248
filterPeak : [ ] ,
179
249
tTrEndPts,
180
250
isUiNoBrushSt : true ,
181
- sweepExtentSt : sweepExtentSubViewSt ,
251
+ sweepExtentSt : sweepExtent [ 2 ] ,
182
252
} ) ;
183
253
drawLabel ( this . rootKlassRect , null , 'M/Z' , 'Intensity' ) ;
184
254
drawDisplay ( this . rootKlassRect , false ) ;
@@ -188,11 +258,14 @@ class ViewerLineRect extends React.Component {
188
258
const {
189
259
entities, curveSt, seed, cLabel, xLabel, yLabel,
190
260
tTrEndPts, layoutSt,
191
- sweepExtentSt , isUiAddIntgSt, isUiNoBrushSt,
192
- isHidden, sweepExtentSubViewSt ,
261
+ isUiAddIntgSt, isUiNoBrushSt,
262
+ isHidden, uiSt ,
193
263
} = this . props ;
194
264
this . normChange ( prevProps ) ;
195
265
266
+ const { zoom } = uiSt ;
267
+ const { sweepExtent } = zoom ;
268
+
196
269
const uvvisViewFeature = this . extractUvvisView ( ) ;
197
270
if ( uvvisViewFeature ) {
198
271
const { data } = uvvisViewFeature ;
@@ -207,7 +280,7 @@ class ViewerLineRect extends React.Component {
207
280
filterPeak : [ ] ,
208
281
tTrEndPts,
209
282
isUiNoBrushSt : true ,
210
- sweepExtentSt : sweepExtentSubViewSt ,
283
+ sweepExtentSt : sweepExtent [ 0 ] ,
211
284
} ) ;
212
285
drawLabel ( this . rootKlassLine , null , 'M/Z' , 'Intensity' ) ;
213
286
drawDisplay ( this . rootKlassLine , false ) ;
@@ -221,7 +294,7 @@ class ViewerLineRect extends React.Component {
221
294
filterSeed,
222
295
tTrEndPts,
223
296
layoutSt,
224
- sweepExtentSt,
297
+ sweepExtentSt : sweepExtent [ 1 ] ,
225
298
isUiAddIntgSt,
226
299
isUiNoBrushSt,
227
300
} ) ;
@@ -242,7 +315,7 @@ class ViewerLineRect extends React.Component {
242
315
filterPeak : [ ] ,
243
316
tTrEndPts,
244
317
isUiNoBrushSt : true ,
245
- sweepExtentSt : sweepExtentSubViewSt ,
318
+ sweepExtentSt : sweepExtent [ 2 ] ,
246
319
} ) ;
247
320
drawLabel ( this . rootKlassRect , `${ pageValue } min` , xUnit , 'Intensity' ) ;
248
321
drawDisplay ( this . rootKlassRect , false ) ;
@@ -296,29 +369,37 @@ class ViewerLineRect extends React.Component {
296
369
297
370
render ( ) {
298
371
const {
299
- hplcMsSt, selectWavelengthAct, updateTicAct, selectCurveAct,
300
- feature,
372
+ classes , hplcMsSt, selectWavelengthAct, updateTicAct, selectCurveAct,
373
+ feature, zoomInAct , uiSt ,
301
374
} = this . props ;
302
375
const handleTicChanged = ( event ) => {
303
376
updateTicAct ( event ) ;
304
377
selectCurveAct ( event . target . value ) ;
305
378
} ;
306
379
return (
307
380
< div >
381
+ {
382
+ zoomView ( classNames , 0 , uiSt , zoomInAct )
383
+ }
308
384
< div style = { { textAlign : 'right' } } >
309
385
{
310
- waveLengthSelect ( classNames , hplcMsSt , selectWavelengthAct )
386
+ waveLengthSelect ( classes , hplcMsSt , selectWavelengthAct )
311
387
}
312
388
< div className = { LIST_ROOT_SVG_GRAPH . LINE } />
313
389
</ div >
314
- < PeakGroup feature = { feature } />
390
+ < PeakGroup feature = { feature } graphIndex = { 1 } />
391
+ {
392
+ zoomView ( classes , 1 , uiSt , zoomInAct )
393
+ }
315
394
< div style = { { textAlign : 'right' } } >
316
395
{
317
- ticSelect ( classNames , hplcMsSt , handleTicChanged )
396
+ ticSelect ( classes , hplcMsSt , handleTicChanged )
318
397
}
319
398
< div className = { LIST_ROOT_SVG_GRAPH . MULTI } />
320
399
</ div >
321
- < Zoom isSubView />
400
+ {
401
+ zoomView ( classes , 2 , uiSt , zoomInAct )
402
+ }
322
403
< div className = { LIST_ROOT_SVG_GRAPH . RECT } />
323
404
</ div >
324
405
) ;
@@ -330,8 +411,6 @@ const mapStateToProps = (state, props) => (
330
411
curveSt : state . curve ,
331
412
seed : Topic2Seed ( state , props ) ,
332
413
tTrEndPts : ToThresEndPts ( state , props ) ,
333
- sweepExtentSt : state . ui . sweepExtent ,
334
- sweepExtentSubViewSt : state . ui . sweepExtentSubView ,
335
414
isUiAddIntgSt : state . ui . sweepType === LIST_UI_SWEEP_TYPE . INTEGRATION_ADD ,
336
415
isUiNoBrushSt : LIST_NON_BRUSH_TYPES . indexOf ( state . ui . sweepType ) < 0 ,
337
416
uiSt : state . ui ,
@@ -348,10 +427,12 @@ const mapDispatchToProps = (dispatch) => (
348
427
selectWavelengthAct : selectWavelength ,
349
428
updateTicAct : changeTic ,
350
429
selectCurveAct : selectCurve ,
430
+ zoomInAct : setUiSweepType ,
351
431
} , dispatch )
352
432
) ;
353
433
354
434
ViewerLineRect . propTypes = {
435
+ classes : PropTypes . object . isRequired ,
355
436
uiSt : PropTypes . object . isRequired ,
356
437
curveSt : PropTypes . object . isRequired ,
357
438
entities : PropTypes . array . isRequired ,
@@ -363,8 +444,6 @@ ViewerLineRect.propTypes = {
363
444
layoutSt : PropTypes . string . isRequired ,
364
445
feature : PropTypes . object . isRequired ,
365
446
tTrEndPts : PropTypes . array . isRequired ,
366
- sweepExtentSt : PropTypes . object . isRequired ,
367
- sweepExtentSubViewSt : PropTypes . object . isRequired ,
368
447
isUiAddIntgSt : PropTypes . bool . isRequired ,
369
448
isUiNoBrushSt : PropTypes . bool . isRequired ,
370
449
resetAllAct : PropTypes . func . isRequired ,
@@ -376,6 +455,11 @@ ViewerLineRect.propTypes = {
376
455
selectWavelengthAct : PropTypes . func . isRequired ,
377
456
updateTicAct : PropTypes . func . isRequired ,
378
457
selectCurveAct : PropTypes . func . isRequired ,
458
+ zoomInAct : PropTypes . func . isRequired ,
379
459
} ;
380
460
381
- export default connect ( mapStateToProps , mapDispatchToProps ) ( ViewerLineRect ) ;
461
+ // export default connect(mapStateToProps, mapDispatchToProps)(ViewerLineRect);
462
+ export default compose (
463
+ connect ( mapStateToProps , mapDispatchToProps ) ,
464
+ withStyles ( styles ) ,
465
+ ) ( ViewerLineRect ) ;
0 commit comments