Skip to content

Commit

Permalink
feat: display threshold for multiple spectra
Browse files Browse the repository at this point in the history
  • Loading branch information
Lan Le committed Aug 12, 2024
1 parent ba84a45 commit d171a17
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
23 changes: 23 additions & 0 deletions dist/components/d3_multi/multi_focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class MultiFocus {
this.brushX = d3.brushX();
this.axis = null;
this.path = null;
this.thresLineUp = null;
this.thresLineDw = null;
this.grid = null;
this.tags = null;
this.ref = null;
Expand Down Expand Up @@ -79,6 +81,7 @@ class MultiFocus {
this.update = this.update.bind(this);
this.setConfig = this.setConfig.bind(this);
this.drawLine = this.drawLine.bind(this);
this.drawThres = this.drawThres.bind(this);
this.drawOtherLines = this.drawOtherLines.bind(this);
this.drawGrid = this.drawGrid.bind(this);
this.drawPeaks = this.drawPeaks.bind(this);
Expand Down Expand Up @@ -258,6 +261,23 @@ class MultiFocus {
this.path.attr('marker-mid', 'url(#arrow-left)');
}
}
drawThres() {
if (this.tTrEndPts.length > 0) {
this.thresLineUp.attr('d', this.pathCall(this.tTrEndPts));
this.thresLineUp.attr('visibility', 'visible');
const [left, right] = this.tTrEndPts;
const dwMirrorEndPts = [Object.assign({}, left, {
y: -left.y
}), Object.assign({}, right, {
y: -right.y
})];
this.thresLineDw.attr('d', this.pathCall(dwMirrorEndPts));
this.thresLineDw.attr('visibility', 'visible');
} else {
this.thresLineUp.attr('visibility', 'hidden');
this.thresLineDw.attr('visibility', 'hidden');
}
}
drawOtherLines(layout) {
d3.selectAll('.line-clip-compare').remove();
if (!this.otherLineData) return null;
Expand Down Expand Up @@ -819,6 +839,7 @@ class MultiFocus {
(0, _compass.MountCompass)(this);
this.axis = (0, _mount.MountAxis)(this);
this.path = (0, _mount.MountPath)(this, this.pathColor);
[this.thresLineUp, this.thresLineDw] = (0, _mount.MountThresLine)(this, 'green');
this.grid = (0, _mount.MountGrid)(this);
this.tags = (0, _mount.MountTags)(this);
this.ref = (0, _mount.MountRef)(this);
Expand All @@ -827,6 +848,7 @@ class MultiFocus {
if (this.data && this.data.length > 0) {
this.setConfig(sweepExtentSt);
this.drawLine();
this.drawThres();
this.drawGrid();
this.drawOtherLines(layoutSt);
this.drawPeaks(editPeakSt);
Expand Down Expand Up @@ -868,6 +890,7 @@ class MultiFocus {
this.setConfig(sweepExtentSt);
this.getShouldUpdate(editPeakSt);
this.drawLine();
this.drawThres();
this.drawGrid();
this.drawOtherLines(layoutSt);
this.drawPeaks(editPeakSt);
Expand Down
2 changes: 1 addition & 1 deletion dist/components/multi_jcamps_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class MultiJcampsViewer extends _react.default.Component {
feature: feature,
operations: operations,
editorOnly: true,
hideThreshold: true
hideThreshold: !_format.default.isNmrLayout(layoutSt)
}), /*#__PURE__*/_react.default.createElement("div", {
className: "react-spectrum-editor"
}, /*#__PURE__*/_react.default.createElement(_Grid.default, {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@complat/react-spectra-editor",
"version": "1.3.4",
"version": "1.3.5",
"description": "An editor to View and Edit Chemical Spectra data (NMR, IR, MS, CV, UIVIS, XRD, GC, and DSC).",
"repository": {
"type": "git",
Expand Down
24 changes: 24 additions & 0 deletions src/components/d3_multi/multi_focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import {
MountPath, MountGrid, MountAxis, MountAxisLabelX, MountAxisLabelY,
MountClip, MountMainFrame, MountTags, MountComparePath, MountRef,
MountThresLine,
} from '../../helpers/mount';
import { PksEdit, PeckersEdit } from '../../helpers/converter';
import MountBrush from '../../helpers/brush';
Expand Down Expand Up @@ -49,6 +50,8 @@ class MultiFocus {

this.axis = null;
this.path = null;
this.thresLineUp = null;
this.thresLineDw = null;
this.grid = null;
this.tags = null;
this.ref = null;
Expand Down Expand Up @@ -78,6 +81,7 @@ class MultiFocus {
this.update = this.update.bind(this);
this.setConfig = this.setConfig.bind(this);
this.drawLine = this.drawLine.bind(this);
this.drawThres = this.drawThres.bind(this);
this.drawOtherLines = this.drawOtherLines.bind(this);
this.drawGrid = this.drawGrid.bind(this);
this.drawPeaks = this.drawPeaks.bind(this);
Expand Down Expand Up @@ -228,6 +232,23 @@ class MultiFocus {
}
}

drawThres() {
if (this.tTrEndPts.length > 0) {
this.thresLineUp.attr('d', this.pathCall(this.tTrEndPts));
this.thresLineUp.attr('visibility', 'visible');
const [left, right] = this.tTrEndPts;
const dwMirrorEndPts = [
Object.assign({}, left, { y: -left.y }),
Object.assign({}, right, { y: -right.y }),
];
this.thresLineDw.attr('d', this.pathCall(dwMirrorEndPts));
this.thresLineDw.attr('visibility', 'visible');
} else {
this.thresLineUp.attr('visibility', 'hidden');
this.thresLineDw.attr('visibility', 'hidden');
}
}

drawOtherLines(layout) {
d3.selectAll('.line-clip-compare').remove();
if (!this.otherLineData) return null;
Expand Down Expand Up @@ -1007,6 +1028,7 @@ class MultiFocus {

this.axis = MountAxis(this);
this.path = MountPath(this, this.pathColor);
[this.thresLineUp, this.thresLineDw] = MountThresLine(this, 'green');
this.grid = MountGrid(this);
this.tags = MountTags(this);
this.ref = MountRef(this);
Expand All @@ -1016,6 +1038,7 @@ class MultiFocus {
if (this.data && this.data.length > 0) {
this.setConfig(sweepExtentSt);
this.drawLine();
this.drawThres();
this.drawGrid();
this.drawOtherLines(layoutSt);
this.drawPeaks(editPeakSt);
Expand Down Expand Up @@ -1049,6 +1072,7 @@ class MultiFocus {
this.setConfig(sweepExtentSt);
this.getShouldUpdate(editPeakSt);
this.drawLine();
this.drawThres();
this.drawGrid();
this.drawOtherLines(layoutSt);
this.drawPeaks(editPeakSt);
Expand Down
2 changes: 1 addition & 1 deletion src/components/multi_jcamps_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class MultiJcampsViewer extends React.Component { // eslint-disable-line
feature={feature}
operations={operations}
editorOnly={true}
hideThreshold={true}
hideThreshold={!Format.isNmrLayout(layoutSt)}
/>
<div className="react-spectrum-editor">
<Grid container>
Expand Down

0 comments on commit d171a17

Please sign in to comment.