Skip to content

Commit f30d2d6

Browse files
author
Lan Le
committed
feat WIP: update handle select tic
1 parent 9c725dd commit f30d2d6

File tree

5 files changed

+120
-16
lines changed

5 files changed

+120
-16
lines changed

src/actions/hplcms.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const selectWavelength = (payload) => (
99

1010
const changeTic = (payload) => (
1111
{
12-
type: HPLC_MS.UPDATE_UVVIS_WAVE_LENGTH,
12+
type: HPLC_MS.SELECT_TIC_CURVE,
1313
payload,
1414
}
1515
);

src/components/d3_line_rect/index.js

+78-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
} from '../../helpers/chem';
1414
import { resetAll } from '../../actions/manager';
1515
import { selectUiSweep, scrollUiWheel, clickUiTarget } from '../../actions/ui';
16-
import { selectWavelength } from '../../actions/hplcms';
16+
import { selectWavelength, changeTic } from '../../actions/hplcms';
17+
import { selectCurve } from '../../actions/curve';
1718
import RectFocus from './rect_focus';
1819
import MultiFocus from './multi_focus';
1920
import LineFocus from './line_focus';
@@ -30,7 +31,8 @@ const W = Math.round(window.innerWidth * 0.90 * 9 / 12); // ROI
3031
const H = Math.round(window.innerHeight * 0.90 * 0.85 / 3); // ROI
3132

3233
const waveLengthSelect = (classes, hplcMsSt, updateWaveLengthAct) => {
33-
const { listWaveLength, selectedWaveLength } = hplcMsSt;
34+
const { uvvis } = hplcMsSt;
35+
const { listWaveLength, selectedWaveLength } = uvvis;
3436
const options = listWaveLength.map((d) => (
3537
<MenuItem value={d} key={d}>
3638
<span className={classNames(classes.txtOpt, 'option-sv-bar-decimal')}>
@@ -60,6 +62,38 @@ const waveLengthSelect = (classes, hplcMsSt, updateWaveLengthAct) => {
6062
);
6163
};
6264

65+
const ticSelect = (classes, hplcMsSt, updateTicAct) => {
66+
const { tic } = hplcMsSt;
67+
const { isNegative } = tic;
68+
const listTIC = [{ name: 'PLUS', value: 0 }, { name: 'MINUS', value: 1 }];
69+
const options = listTIC.map((d) => (
70+
<MenuItem value={d.value} key={d.value}>
71+
<span className={classNames(classes.txtOpt, 'option-sv-bar-decimal')}>
72+
{d.name}
73+
</span>
74+
</MenuItem>
75+
));
76+
77+
return (
78+
<FormControl
79+
className={classNames(classes.fieldDecimal)}
80+
variant="outlined"
81+
>
82+
<InputLabel id="select-decimal-label" className={classNames(classes.selectLabel, 'select-sv-bar-label')}>
83+
TIC
84+
</InputLabel>
85+
<Select
86+
labelId="select-decimal-label"
87+
label="Decimal"
88+
value={isNegative ? 1 : 0}
89+
onChange={updateTicAct}
90+
className={classNames(classes.selectInput, 'input-sv-bar-decimal')}
91+
>
92+
{ options }
93+
</Select>
94+
</FormControl>
95+
);
96+
};
6397
class ViewerLineRect extends React.Component {
6498
constructor(props) {
6599
super(props);
@@ -97,6 +131,8 @@ class ViewerLineRect extends React.Component {
97131
resetAllAct,
98132
} = this.props;
99133
drawDestroy(this.rootKlassMulti);
134+
drawDestroy(this.rootKlassLine);
135+
drawDestroy(this.rootKlassRect);
100136
resetAllAct(feature);
101137

102138
const uvvisViewFeature = this.extractUvvisView();
@@ -155,6 +191,26 @@ class ViewerLineRect extends React.Component {
155191
} = this.props;
156192
this.normChange(prevProps);
157193

194+
const uvvisViewFeature = this.extractUvvisView();
195+
if (uvvisViewFeature) {
196+
const { data } = uvvisViewFeature;
197+
const currentData = data[0];
198+
const { x, y } = currentData;
199+
const uvvisSeed = x.map((d, index) => {
200+
const s = { x: d, y: y[index] };
201+
return s;
202+
});
203+
this.lineFocus.update({
204+
filterSeed: uvvisSeed,
205+
filterPeak: [],
206+
tTrEndPts,
207+
isUiNoBrushSt: true,
208+
sweepExtentSt: sweepExtentSubViewSt,
209+
});
210+
drawLabel(this.rootKlassLine, null, 'M/Z', 'Intensity');
211+
drawDisplay(this.rootKlassLine, false);
212+
}
213+
158214
const filterSeed = seed;
159215

160216
this.multiFocus.update({
@@ -208,14 +264,16 @@ class ViewerLineRect extends React.Component {
208264
const {
209265
features,
210266
} = extractParams(subEntities[0], 0, 1);
211-
const { wavelengthIdx } = hplcMsSt;
267+
const { uvvis } = hplcMsSt;
268+
const { wavelengthIdx } = uvvis;
212269
return features[wavelengthIdx];
213270
}
214271

215272
extractSubView() {
216-
const { uiSt, subEntities, curveSt } = this.props;
217-
const { curveIdx } = curveSt;
218-
const entityIdx = curveIdx === 0 ? 1 : 2;
273+
const { uiSt, subEntities, hplcMsSt } = this.props;
274+
const { tic } = hplcMsSt;
275+
const { isNegative } = tic;
276+
const entityIdx = isNegative ? 2 : 1;
219277
const { subViewerAt } = uiSt;
220278
let selectFeature = null;
221279

@@ -235,13 +293,22 @@ class ViewerLineRect extends React.Component {
235293
}
236294

237295
render() {
238-
const { hplcMsSt, selectWavelengthAct } = this.props;
296+
const {
297+
hplcMsSt, selectWavelengthAct, updateTicAct, selectCurveAct,
298+
} = this.props;
299+
const handleTicChanged = (event) => {
300+
updateTicAct(event);
301+
selectCurveAct(event.target.value);
302+
};
239303
return (
240304
<div>
241305
{
242306
waveLengthSelect(classNames, hplcMsSt, selectWavelengthAct)
243307
}
244308
<div className={LIST_ROOT_SVG_GRAPH.LINE} />
309+
{
310+
ticSelect(classNames, hplcMsSt, handleTicChanged)
311+
}
245312
<div className={LIST_ROOT_SVG_GRAPH.MULTI} />
246313
<Zoom isSubView />
247314
<div className={LIST_ROOT_SVG_GRAPH.RECT} />
@@ -271,6 +338,8 @@ const mapDispatchToProps = (dispatch) => (
271338
selectUiSweepAct: selectUiSweep,
272339
scrollUiWheelAct: scrollUiWheel,
273340
selectWavelengthAct: selectWavelength,
341+
updateTicAct: changeTic,
342+
selectCurveAct: selectCurve,
274343
}, dispatch)
275344
);
276345

@@ -297,6 +366,8 @@ ViewerLineRect.propTypes = {
297366
isHidden: PropTypes.bool.isRequired,
298367
hplcMsSt: PropTypes.bool.isRequired,
299368
selectWavelengthAct: PropTypes.func.isRequired,
369+
updateTicAct: PropTypes.func.isRequired,
370+
selectCurveAct: PropTypes.func.isRequired,
300371
};
301372

302373
export default connect(mapStateToProps, mapDispatchToProps)(ViewerLineRect);

src/components/panel/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable react/prop-types, react/require-default-props */
1+
/* eslint-disable react/prop-types, react/require-default-props, max-len */
22
import React from 'react';
33
import PropTypes from 'prop-types';
44
import classNames from 'classnames';
@@ -18,6 +18,7 @@ import MultiplicityPanel from './multiplicity';
1818
import CyclicVoltammetryPanel from './cyclic_voltamery_data';
1919
import GraphSelectionPanel from './graph_selection';
2020
import Cfg from '../../helpers/cfg';
21+
import Format from '../../helpers/format';
2122

2223
const theme = createTheme({
2324
typography: {
@@ -82,7 +83,7 @@ class PanelViewer extends React.Component {
8283
const onExapndGraphSelection = () => this.onExapnd('graph');
8384

8485
const { listCurves } = curveSt;
85-
const hideGraphSelection = listCurves === false || listCurves === undefined;
86+
const hideGraphSelection = listCurves === false || listCurves === undefined || Format.isLCMsLayout(layoutSt);
8687

8788
return (
8889
<div className={classNames(classes.panels)}>

src/constants/action_type.js

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ const SEC = {
168168

169169
const HPLC_MS = {
170170
UPDATE_UVVIS_WAVE_LENGTH: 'UPDATE_UVVIS_WAVE_LENGTH',
171+
SELECT_TIC_CURVE: 'SELECT_TIC_CURVE',
171172
};
172173

173174
export {

src/reducers/reducer_hplc_ms.js

+37-6
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ import { HPLC_MS, CURVE } from '../constants/action_type';
33
import Format from '../helpers/format';
44

55
const initialState = {
6-
listWaveLength: null,
7-
selectedWaveLength: null,
8-
wavelengthIdx: 0,
6+
uvvis: {
7+
listWaveLength: null,
8+
selectedWaveLength: null,
9+
wavelengthIdx: 0,
10+
},
11+
tic: {
12+
isNegative: false,
13+
},
914
};
1015

1116
const updateHPLCData = (state, action) => {
@@ -18,24 +23,48 @@ const updateHPLCData = (state, action) => {
1823
const uvvisCurve = payload[2];
1924
const { features } = uvvisCurve;
2025
const listWaveLength = features.map((fe) => fe.pageValue);
21-
return Object.assign({}, state, {
26+
const { uvvis } = state;
27+
const newUvvis = Object.assign({}, uvvis, {
2228
listWaveLength,
2329
selectedWaveLength: listWaveLength[0],
2430
});
31+
return Object.assign({}, state, {
32+
uvvis: newUvvis,
33+
});
2534
}
2635
return state;
2736
};
2837

2938
const updateWaveLength = (state, action) => {
3039
const { payload } = action;
31-
const { listWaveLength } = state;
3240
if (payload) {
3341
const { value } = payload.target;
42+
const { uvvis } = state;
43+
const { listWaveLength } = uvvis;
3444
const wavelengthIdx = listWaveLength.indexOf(value);
35-
return Object.assign({}, state, {
45+
const newUvvis = Object.assign({}, uvvis, {
3646
selectedWaveLength: value,
3747
wavelengthIdx,
3848
});
49+
return Object.assign({}, state, {
50+
uvvis: newUvvis,
51+
});
52+
}
53+
return state;
54+
};
55+
56+
const updateTic = (state, action) => {
57+
const { payload } = action;
58+
if (payload) {
59+
const { value } = payload.target;
60+
const { tic } = state;
61+
const isNegative = value === 1;
62+
const newTic = Object.assign({}, tic, {
63+
isNegative,
64+
});
65+
return Object.assign({}, state, {
66+
tic: newTic,
67+
});
3968
}
4069
return state;
4170
};
@@ -46,6 +75,8 @@ const hplcmsReducer = (state = initialState, action) => {
4675
return updateHPLCData(state, action);
4776
case HPLC_MS.UPDATE_UVVIS_WAVE_LENGTH:
4877
return updateWaveLength(state, action);
78+
case HPLC_MS.SELECT_TIC_CURVE:
79+
return updateTic(state, action);
4980
default:
5081
return state;
5182
}

0 commit comments

Comments
 (0)