Skip to content

Commit 1c80817

Browse files
author
Lan Le
committed
feat: add threshold for multi spectra (#229)
1 parent 7fc69e2 commit 1c80817

26 files changed

+3754
-2066
lines changed

dist/components/cmd_bar/03_peak.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ const mapStateToProps = (state, props) => (
135135
cyclicVotaSt: state.cyclicvolta,
136136
curveSt: state.curve,
137137
editPeakSt: state.editPeak.present,
138-
thresSt: state.threshold,
138+
thresSt: state.threshold.list[state.curve.curveIdx],
139139
layoutSt: state.layout,
140140
shiftSt: state.shift
141141
});

dist/components/cmd_bar/r03_threshold.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,24 @@ const txtPercent = () => /*#__PURE__*/_react.default.createElement(_material.Inp
3232
}, /*#__PURE__*/_react.default.createElement("span", {
3333
className: "txt-percent"
3434
}, "%"));
35-
const setThreshold = (classes, thresVal, updateThresholdValueAct) => {
36-
const onBlur = e => updateThresholdValueAct(e.target.value);
37-
const onChange = e => updateThresholdValueAct(e.target.value);
35+
const setThreshold = (classes, thresVal, updateThresholdValueAct, curveSt) => {
36+
const {
37+
curveIdx
38+
} = curveSt;
39+
const onBlur = e => updateThresholdValueAct({
40+
value: e.target.value,
41+
curveIdx
42+
});
43+
const onChange = e => updateThresholdValueAct({
44+
value: e.target.value,
45+
curveIdx
46+
});
3847
const onEnterPress = e => {
3948
if (e.key === 'Enter') {
40-
updateThresholdValueAct(e.target.value);
49+
updateThresholdValueAct({
50+
value: e.target.value,
51+
curveIdx
52+
});
4153
}
4254
};
4355
return /*#__PURE__*/_react.default.createElement(_material.FormControl, {
@@ -78,14 +90,15 @@ const Threshold = _ref => {
7890
hideThresSt,
7991
thresValSt,
8092
isEditSt,
93+
curveSt,
8194
updateThresholdValueAct,
8295
resetThresholdValueAct,
8396
toggleThresholdIsEditAct
8497
} = _ref;
8598
const thresVal = thresValSt || feature.thresRef;
8699
return /*#__PURE__*/_react.default.createElement("span", {
87100
className: classes.groupRight
88-
}, setThreshold(classes, thresVal, updateThresholdValueAct), /*#__PURE__*/_react.default.createElement(_material.Tooltip, {
101+
}, setThreshold(classes, thresVal, updateThresholdValueAct, curveSt), /*#__PURE__*/_react.default.createElement(_material.Tooltip, {
89102
title: /*#__PURE__*/_react.default.createElement("span", {
90103
className: "txt-sv-tp"
91104
}, "Restore Threshold")
@@ -109,8 +122,9 @@ const mapStateToProps = (state, props) => (
109122
// eslint-disable-line
110123
{
111124
hideThresSt: _cfg.default.hideCmdThres(state.layout),
112-
isEditSt: state.threshold.isEdit,
113-
thresValSt: parseFloat(state.threshold.value) || 0
125+
isEditSt: state.threshold.list[state.curve.curveIdx].isEdit,
126+
thresValSt: parseFloat(state.threshold.list[state.curve.curveIdx].value) || 0,
127+
curveSt: state.curve
114128
});
115129
const mapDispatchToProps = dispatch => (0, _redux.bindActionCreators)({
116130
updateThresholdValueAct: _threshold.updateThresholdValue,
@@ -124,6 +138,7 @@ Threshold.propTypes = {
124138
hideThresSt: _propTypes.default.bool.isRequired,
125139
isEditSt: _propTypes.default.bool.isRequired,
126140
thresValSt: _propTypes.default.number.isRequired,
141+
curveSt: _propTypes.default.object.isRequired,
127142
updateThresholdValueAct: _propTypes.default.func.isRequired,
128143
resetThresholdValueAct: _propTypes.default.func.isRequired,
129144
toggleThresholdIsEditAct: _propTypes.default.func.isRequired

dist/components/cmd_bar/r05_submit_btn.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const mapStateToProps = (state, props) => (
9393
// eslint-disable-line
9494
{
9595
editPeakSt: state.editPeak.present,
96-
thresSt: state.threshold,
96+
thresSt: state.threshold.list[state.curve.curveIdx],
9797
layoutSt: state.layout,
9898
shiftSt: state.shift,
9999
scanSt: state.scan,

dist/components/cmd_bar/r06_predict_btn.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ const mapStateToProps = (state, props) => (
194194
editPeakSt: state.editPeak.present,
195195
scanSt: state.scan,
196196
shiftSt: state.shift,
197-
thresSt: state.threshold,
197+
thresSt: state.threshold.list[state.curve.curveIdx],
198198
integrationSt: state.integration.present,
199199
multiplicitySt: state.multiplicity.present,
200200
curveSt: state.curve

dist/components/d3_multi/multi_focus.js

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var _integration = require("../../helpers/integration");
1919
var _multiplicity_calc = require("../../helpers/multiplicity_calc");
2020
var _calc = require("../../helpers/calc");
2121
/* eslint-disable no-unused-vars, prefer-object-spread, no-mixed-operators,
22-
no-unneeded-ternary, arrow-body-style */
22+
no-unneeded-ternary, arrow-body-style, max-len */
2323

2424
const d3 = require('d3');
2525
class MultiFocus {
@@ -51,6 +51,8 @@ class MultiFocus {
5151
this.brushX = d3.brushX();
5252
this.axis = null;
5353
this.path = null;
54+
this.thresLineUp = null;
55+
this.thresLineDw = null;
5456
this.grid = null;
5557
this.tags = null;
5658
this.ref = null;
@@ -79,6 +81,7 @@ class MultiFocus {
7981
this.update = this.update.bind(this);
8082
this.setConfig = this.setConfig.bind(this);
8183
this.drawLine = this.drawLine.bind(this);
84+
this.drawThres = this.drawThres.bind(this);
8285
this.drawOtherLines = this.drawOtherLines.bind(this);
8386
this.drawGrid = this.drawGrid.bind(this);
8487
this.drawPeaks = this.drawPeaks.bind(this);
@@ -155,8 +158,8 @@ class MultiFocus {
155158
this.tip = (0, _init.InitTip)();
156159
this.root.call(this.tip);
157160
}
158-
setDataParams(peaks, tTrEndPts, tSfPeaks, layout, cyclicvoltaSt) {
159-
let jcampIdx = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
161+
setDataParams(filterSeed, peaks, tTrEndPts, tSfPeaks, layout, cyclicvoltaSt) {
162+
let jcampIdx = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;
160163
this.data = [];
161164
this.otherLineData = [];
162165
let filterSubLayoutValue = null;
@@ -167,8 +170,11 @@ class MultiFocus {
167170
color
168171
} = entry;
169172
const offset = (0, _chem.GetCyclicVoltaPreviousShift)(cyclicvoltaSt, jcampIdx);
170-
const currData = (0, _chem.convertTopic)(topic, layout, feature, offset);
173+
let currData = (0, _chem.convertTopic)(topic, layout, feature, offset);
171174
if (idx === jcampIdx) {
175+
if (!_format.default.isCyclicVoltaLayout(layout)) {
176+
currData = filterSeed;
177+
}
172178
this.data = [...currData];
173179
this.pathColor = color;
174180
filterSubLayoutValue = _format.default.isSECLayout(layout) ? feature.xUnit : feature.yUnit;
@@ -258,6 +264,23 @@ class MultiFocus {
258264
this.path.attr('marker-mid', 'url(#arrow-left)');
259265
}
260266
}
267+
drawThres() {
268+
if (this.tTrEndPts.length > 0) {
269+
this.thresLineUp.attr('d', this.pathCall(this.tTrEndPts));
270+
this.thresLineUp.attr('visibility', 'visible');
271+
const [left, right] = this.tTrEndPts;
272+
const dwMirrorEndPts = [Object.assign({}, left, {
273+
y: -left.y
274+
}), Object.assign({}, right, {
275+
y: -right.y
276+
})];
277+
this.thresLineDw.attr('d', this.pathCall(dwMirrorEndPts));
278+
this.thresLineDw.attr('visibility', 'visible');
279+
} else {
280+
this.thresLineUp.attr('visibility', 'hidden');
281+
this.thresLineDw.attr('visibility', 'hidden');
282+
}
283+
}
261284
drawOtherLines(layout) {
262285
d3.selectAll('.line-clip-compare').remove();
263286
if (!this.otherLineData) return null;
@@ -815,10 +838,11 @@ class MultiFocus {
815838
this.root = d3.select(this.rootKlass).selectAll('.focus-main');
816839
this.scales = (0, _init.InitScale)(this, this.reverseXAxis(layoutSt));
817840
this.setTip();
818-
this.setDataParams(filterPeak, tTrEndPts, tSfPeaks, layoutSt, cyclicvoltaSt, jcampIdx);
841+
this.setDataParams(filterSeed, filterPeak, tTrEndPts, tSfPeaks, layoutSt, cyclicvoltaSt, jcampIdx);
819842
(0, _compass.MountCompass)(this);
820843
this.axis = (0, _mount.MountAxis)(this);
821844
this.path = (0, _mount.MountPath)(this, this.pathColor);
845+
[this.thresLineUp, this.thresLineDw] = (0, _mount.MountThresLine)(this, 'green');
822846
this.grid = (0, _mount.MountGrid)(this);
823847
this.tags = (0, _mount.MountTags)(this);
824848
this.ref = (0, _mount.MountRef)(this);
@@ -827,6 +851,7 @@ class MultiFocus {
827851
if (this.data && this.data.length > 0) {
828852
this.setConfig(sweepExtentSt);
829853
this.drawLine();
854+
this.drawThres();
830855
this.drawGrid();
831856
this.drawOtherLines(layoutSt);
832857
this.drawPeaks(editPeakSt);
@@ -863,11 +888,12 @@ class MultiFocus {
863888
const jcampIdx = curveIdx;
864889
this.isShowAllCurves = isShowAllCurve;
865890
this.entities = entities;
866-
this.setDataParams(filterPeak, tTrEndPts, tSfPeaks, layoutSt, cyclicvoltaSt, jcampIdx);
891+
this.setDataParams(filterSeed, filterPeak, tTrEndPts, tSfPeaks, layoutSt, cyclicvoltaSt, jcampIdx);
867892
if (this.data && this.data.length > 0) {
868893
this.setConfig(sweepExtentSt);
869894
this.getShouldUpdate(editPeakSt);
870895
this.drawLine();
896+
this.drawThres();
871897
this.drawGrid();
872898
this.drawOtherLines(layoutSt);
873899
this.drawPeaks(editPeakSt);

dist/components/multi_jcamps_viewer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class MultiJcampsViewer extends _react.default.Component {
8888
feature: feature,
8989
operations: operations,
9090
editorOnly: true,
91-
hideThreshold: true
91+
hideThreshold: !_format.default.isNmrLayout(layoutSt)
9292
}), /*#__PURE__*/_react.default.createElement("div", {
9393
className: "react-spectrum-editor"
9494
}, /*#__PURE__*/_react.default.createElement(_Grid.default, {

dist/helpers/chem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ const convertFrequency = (layout, feature) => {
164164
return parseFloat(freq) || false;
165165
};
166166
const ToFrequency = exports.ToFrequency = (0, _reselect.createSelector)(getLayout, getFeature, convertFrequency);
167-
const getThreshold = state => state.threshold ? state.threshold.value * 1.0 : false;
167+
const getThreshold = state => state.threshold ? state.threshold.list[state.curve.curveIdx].value * 1.0 : false;
168168
const Convert2Peak = function (feature, threshold, offset) {
169169
let upThreshold = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
170170
let lowThreshold = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;

dist/layer_prism.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const mapStateToProps = (state, props) => (
113113
// eslint-disable-line
114114
{
115115
scanSt: state.scan,
116-
thresSt: state.threshold,
116+
thresSt: state.threshold.list[state.curve.curveIdx],
117117
uiSt: state.ui
118118
});
119119
const mapDispatchToProps = dispatch => (0, _redux.bindActionCreators)({}, dispatch);

dist/reducers/reducer_curve.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var _action_type = require("../constants/action_type");
99
var _extractParams = require("../helpers/extractParams");
1010
var _chem = require("../helpers/chem");
1111
var _format = _interopRequireDefault(require("../helpers/format"));
12-
/* eslint-disable prefer-object-spread, default-param-last */
12+
/* eslint-disable prefer-object-spread, default-param-last, max-len */
1313

1414
const initialState = {
1515
listCurves: [],
@@ -26,8 +26,11 @@ const setAllCurves = (state, action) => {
2626
topic,
2727
feature,
2828
hasEdit,
29-
integration
30-
} = (0, _extractParams.extractParams)(entity, 1);
29+
integration,
30+
multiplicity
31+
} = (0, _extractParams.extractParams)(entity, {
32+
isEdit: true
33+
});
3134
// const layout = entity.layout;
3235
const {
3336
layout
@@ -40,6 +43,7 @@ const setAllCurves = (state, action) => {
4043
feature,
4144
hasEdit,
4245
integration,
46+
multiplicity,
4347
maxminPeak,
4448
color,
4549
curveIdx: idx

0 commit comments

Comments
 (0)