nmrium 0.19.1 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/component/1d/Chart1D.js +3 -3
- package/lib/component/1d/ExclusionZoneAnnotation.d.ts +11 -0
- package/lib/component/1d/ExclusionZoneAnnotation.js +18 -0
- package/lib/component/1d/ExclusionZonesAnnotations.d.ts +3 -0
- package/lib/component/1d/ExclusionZonesAnnotations.js +28 -0
- package/lib/component/1d/Line.js +11 -23
- package/lib/component/1d/Viewer1D.js +36 -5
- package/lib/component/1d/ranges/Ranges.js +3 -3
- package/lib/component/1d/{BaseLineZones.d.ts → tool/BaseLineZones.d.ts} +0 -0
- package/lib/component/1d/{BaseLineZones.js → tool/BaseLineZones.js} +5 -5
- package/lib/component/1d/utilities/useIntegralPath.js +9 -10
- package/lib/component/2d/Contours.js +12 -11
- package/lib/component/2d/Left1DChart.js +7 -9
- package/lib/component/2d/Top1DChart.js +7 -7
- package/lib/component/2d/tools/slicing/HorizontalSliceChart.js +7 -7
- package/lib/component/2d/tools/slicing/VerticalSliceChart.js +7 -9
- package/lib/component/EventsTrackers/BrushTracker.js +2 -2
- package/lib/component/EventsTrackers/KeysListenerTracker.js +12 -3
- package/lib/component/NMRium.d.ts +1 -1
- package/lib/component/NMRium.js +28 -25
- package/lib/component/hooks/useActiveSpectrumStyleOptions.d.ts +6 -0
- package/lib/component/hooks/useActiveSpectrumStyleOptions.js +15 -0
- package/lib/component/hooks/useXYReduce.d.ts +2 -1
- package/lib/component/loader/DropZone.js +1 -1
- package/lib/component/modal/ModalStyle.js +5 -2
- package/lib/component/modal/MoleculeStructureEditorModal.js +3 -2
- package/lib/component/modal/MultipleSpectraFiltersModal/index.js +10 -1
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.d.ts +2 -0
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +35 -0
- package/lib/component/panels/MoleculesPanel/MoleculePanel.js +49 -67
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +3 -8
- package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +2 -23
- package/lib/component/panels/Panels.js +10 -0
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DHistogram.js +1 -1
- package/lib/component/panels/ZonesPanel/ZonesTable.js +9 -2
- package/lib/component/reducer/Reducer.d.ts +0 -16
- package/lib/component/reducer/Reducer.js +4 -5
- package/lib/component/reducer/actions/FiltersActions.d.ts +3 -1
- package/lib/component/reducer/actions/FiltersActions.js +60 -18
- package/lib/component/reducer/actions/LoadActions.js +2 -3
- package/lib/component/reducer/actions/MoleculeActions.js +2 -2
- package/lib/component/reducer/actions/PreferencesActions.js +4 -7
- package/lib/component/reducer/actions/RangesActions.js +1 -1
- package/lib/component/reducer/actions/ToolsActions.d.ts +1 -3
- package/lib/component/reducer/actions/ToolsActions.js +1 -30
- package/lib/component/reducer/helper/getRange.d.ts +6 -1
- package/lib/component/reducer/helper/getRange.js +1 -1
- package/lib/component/toolbar/FunctionToolBar.js +2 -5
- package/lib/component/utility/PathBuilder.d.ts +7 -0
- package/lib/component/utility/PathBuilder.js +17 -0
- package/lib/component/utility/getSpectraByNucleus.d.ts +3 -0
- package/lib/component/utility/getSpectraByNucleus.js +4 -0
- package/lib/data/Filters.d.ts +2 -1
- package/lib/data/Filters.js +2 -1
- package/lib/data/data1d/Spectrum1D/ranges/addRange.js +5 -2
- package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +0 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectSignal.d.ts +3 -2
- package/lib/data/data1d/Spectrum1D/ranges/detectSignal.js +23 -15
- package/lib/data/data1d/filter1d/exclusionZones.d.ts +16 -0
- package/lib/data/data1d/filter1d/exclusionZones.js +28 -0
- package/lib/data/types/data1d/ExclusionZone.d.ts +5 -0
- package/lib/data/types/data1d/ExclusionZone.js +1 -0
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/Chart1D.js +3 -3
- package/lib-cjs/component/1d/ExclusionZoneAnnotation.js +23 -0
- package/lib-cjs/component/1d/ExclusionZonesAnnotations.js +52 -0
- package/lib-cjs/component/1d/Line.js +11 -23
- package/lib-cjs/component/1d/Viewer1D.js +36 -5
- package/lib-cjs/component/1d/ranges/Ranges.js +1 -1
- package/lib-cjs/component/1d/{BaseLineZones.js → tool/BaseLineZones.js} +5 -5
- package/lib-cjs/component/1d/utilities/useIntegralPath.js +9 -10
- package/lib-cjs/component/2d/Contours.js +12 -11
- package/lib-cjs/component/2d/Left1DChart.js +7 -9
- package/lib-cjs/component/2d/Top1DChart.js +7 -7
- package/lib-cjs/component/2d/tools/slicing/HorizontalSliceChart.js +7 -7
- package/lib-cjs/component/2d/tools/slicing/VerticalSliceChart.js +7 -9
- package/lib-cjs/component/EventsTrackers/BrushTracker.js +2 -2
- package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +12 -3
- package/lib-cjs/component/NMRium.js +28 -25
- package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +21 -0
- package/lib-cjs/component/loader/DropZone.js +1 -1
- package/lib-cjs/component/modal/ModalStyle.js +5 -2
- package/lib-cjs/component/modal/MoleculeStructureEditorModal.js +3 -2
- package/lib-cjs/component/modal/MultipleSpectraFiltersModal/index.js +10 -1
- package/lib-cjs/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +40 -0
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanel.js +48 -66
- package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +3 -8
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -22
- package/lib-cjs/component/panels/Panels.js +10 -0
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum2DHistogram.js +1 -1
- package/lib-cjs/component/panels/ZonesPanel/ZonesTable.js +8 -1
- package/lib-cjs/component/reducer/Reducer.js +4 -5
- package/lib-cjs/component/reducer/actions/FiltersActions.js +62 -18
- package/lib-cjs/component/reducer/actions/LoadActions.js +2 -3
- package/lib-cjs/component/reducer/actions/MoleculeActions.js +2 -2
- package/lib-cjs/component/reducer/actions/PreferencesActions.js +4 -7
- package/lib-cjs/component/reducer/actions/RangesActions.js +1 -1
- package/lib-cjs/component/reducer/actions/ToolsActions.js +1 -32
- package/lib-cjs/component/reducer/helper/getRange.js +1 -1
- package/lib-cjs/component/toolbar/FunctionToolBar.js +2 -5
- package/lib-cjs/component/utility/PathBuilder.js +21 -0
- package/lib-cjs/component/utility/getSpectraByNucleus.js +11 -0
- package/lib-cjs/data/Filters.js +3 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/addRange.js +5 -2
- package/lib-cjs/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/detectRange.js +0 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/detectSignal.js +24 -15
- package/lib-cjs/data/data1d/filter1d/exclusionZones.js +34 -0
- package/lib-cjs/data/types/data1d/ExclusionZone.js +2 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +21 -21
- package/lib/component/1d/ExclusionZone.d.ts +0 -8
- package/lib/component/1d/ExclusionZone.js +0 -30
- package/lib/component/1d/ExclusionZones.d.ts +0 -2
- package/lib/component/1d/ExclusionZones.js +0 -10
- package/lib-cjs/component/1d/ExclusionZone.js +0 -32
- package/lib-cjs/component/1d/ExclusionZones.js +0 -16
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import ExclusionZones from './ExclusionZones';
|
|
2
|
+
import ExclusionZonesAnnotations from './ExclusionZonesAnnotations';
|
|
4
3
|
import IntegralsSeries from './IntegralsSeries';
|
|
5
4
|
import LinesSeries from './LinesSeries';
|
|
6
5
|
import PeakAnnotations from './PeakAnnotations';
|
|
@@ -9,7 +8,8 @@ import XAxis from './XAxis';
|
|
|
9
8
|
import JGraph from './jCouplingGraph/JGraph';
|
|
10
9
|
import MultiAnalysisRanges from './multiAnalysis/MultiAnalysisRanges';
|
|
11
10
|
import Ranges from './ranges/Ranges';
|
|
11
|
+
import BaseLineZones from './tool/BaseLineZones';
|
|
12
12
|
function Chart1D({ mode, width, height, margin, displayerKey }) {
|
|
13
|
-
return (_jsxs("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, id: "nmrSVG", children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-chart-1d`, children: _jsx("rect", { width: `${width - margin.left - margin.right}`, height: `${height}`, x: `${margin.left}`, y: `${0}` }, void 0) }, void 0) }, void 0), _jsx(LinesSeries, {}, void 0), _jsx(IntegralsSeries, {}, void 0), _jsx(PeakAnnotations, {}, void 0), _jsx(Ranges, {}, void 0), _jsx(JGraph, {}, void 0), _jsx(MultiAnalysisRanges, {}, void 0), _jsx(BaseLineZones, {}, void 0), _jsx(
|
|
13
|
+
return (_jsxs("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, id: "nmrSVG", children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-chart-1d`, children: _jsx("rect", { width: `${width - margin.left - margin.right}`, height: `${height}`, x: `${margin.left}`, y: `${0}` }, void 0) }, void 0) }, void 0), _jsx(LinesSeries, {}, void 0), _jsx(IntegralsSeries, {}, void 0), _jsx(PeakAnnotations, {}, void 0), _jsx(Ranges, {}, void 0), _jsx(JGraph, {}, void 0), _jsx(MultiAnalysisRanges, {}, void 0), _jsx(BaseLineZones, {}, void 0), _jsx(ExclusionZonesAnnotations, {}, void 0), _jsx(ResurrectedDatabaseRanges, {}, void 0), _jsx("g", { className: "container", style: { pointerEvents: 'none' }, children: _jsx(XAxis, { showGrid: true, mode: mode }, void 0) }, void 0)] }, void 0));
|
|
14
14
|
}
|
|
15
15
|
export default Chart1D;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ExclusionZone } from '../../data/types/data1d/ExclusionZone';
|
|
3
|
+
interface ExclusionZoneProps {
|
|
4
|
+
zone: ExclusionZone;
|
|
5
|
+
color: string;
|
|
6
|
+
vAlign: number;
|
|
7
|
+
spectrumID: string;
|
|
8
|
+
}
|
|
9
|
+
declare function ExclusionZoneAnnotation({ zone, color, vAlign, spectrumID, }: ExclusionZoneProps): JSX.Element;
|
|
10
|
+
declare const _default: import("react").MemoExoticComponent<typeof ExclusionZoneAnnotation>;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { useScaleChecked } from '../context/ScaleContext';
|
|
4
|
+
import { HighlightedSource, useHighlight } from '../highlight';
|
|
5
|
+
import useActiveSpectrumStyleOptions from '../hooks/useActiveSpectrumStyleOptions';
|
|
6
|
+
function ExclusionZoneAnnotation({ zone, color, vAlign, spectrumID, }) {
|
|
7
|
+
const { scaleX, scaleY } = useScaleChecked();
|
|
8
|
+
const highlight = useHighlight([zone.id], {
|
|
9
|
+
type: HighlightedSource.EXCLUSION_ZONE,
|
|
10
|
+
extra: { id: zone.id, spectrumID },
|
|
11
|
+
});
|
|
12
|
+
const { opacity } = useActiveSpectrumStyleOptions(spectrumID);
|
|
13
|
+
return (_jsx("g", { transform: `translate(${scaleX()(zone.to)},0)`, children: _jsx("rect", { x: "0", transform: `translate(0,${scaleY()(0) - (vAlign + 5)})`, width: `${scaleX()(zone.from) - scaleX()(zone.to)}`, height: "10px", style: {
|
|
14
|
+
fill: highlight.isActive ? '#ff6f0057' : color,
|
|
15
|
+
opacity,
|
|
16
|
+
}, ...highlight.onHover }, void 0) }, zone.id));
|
|
17
|
+
}
|
|
18
|
+
export default memo(ExclusionZoneAnnotation);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import * as Filters from '../../data/Filters';
|
|
4
|
+
import { useChartData } from '../context/ChartContext';
|
|
5
|
+
import useSpectraByActiveNucleus from '../hooks/useSpectraPerNucleus';
|
|
6
|
+
import { DISPLAYER_MODE } from '../reducer/core/Constants';
|
|
7
|
+
import ExclusionZoneAnnotation from './ExclusionZoneAnnotation';
|
|
8
|
+
import getVerticalShift from './utilities/getVerticalShift';
|
|
9
|
+
function ExclusionZonesAnnotationsInner({ displayerKey, xDomains, spectra, verticalAlign, }) {
|
|
10
|
+
return (_jsx("g", { className: "spectrum-exclusion-zones-group", clipPath: `url(#${displayerKey}clip-chart-1d)`, children: spectra
|
|
11
|
+
.filter((d) => d.display.isVisible === true && xDomains[d.id])
|
|
12
|
+
.map((d, index) => getExclusionZones(d).map((zone) => {
|
|
13
|
+
return (_jsx(ExclusionZoneAnnotation, { spectrumID: d.id, vAlign: getVerticalShift(verticalAlign, { index }), zone: zone, color: d.display.color }, zone.id));
|
|
14
|
+
})) }, void 0));
|
|
15
|
+
}
|
|
16
|
+
const MemoizedPeakAnnotations = memo(ExclusionZonesAnnotationsInner);
|
|
17
|
+
function ExclusionZonesAnnotations() {
|
|
18
|
+
const { displayerKey, xDomains, displayerMode, verticalAlign } = useChartData();
|
|
19
|
+
const spectra = useSpectraByActiveNucleus();
|
|
20
|
+
if (displayerMode !== DISPLAYER_MODE.DM_1D)
|
|
21
|
+
return null;
|
|
22
|
+
return (_jsx(MemoizedPeakAnnotations, { spectra: spectra, displayerKey: displayerKey, xDomains: xDomains, verticalAlign: verticalAlign }, void 0));
|
|
23
|
+
}
|
|
24
|
+
export default ExclusionZonesAnnotations;
|
|
25
|
+
function getExclusionZones(data) {
|
|
26
|
+
return (data.filters.find((filter) => filter.name === Filters.exclusionZones.id)
|
|
27
|
+
?.value || []);
|
|
28
|
+
}
|
package/lib/component/1d/Line.js
CHANGED
|
@@ -1,49 +1,37 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import get from 'lodash/get';
|
|
3
2
|
import { useMemo } from 'react';
|
|
4
3
|
import { useChartData } from '../context/ChartContext';
|
|
5
|
-
import { usePreferences } from '../context/PreferencesContext';
|
|
6
4
|
import { useScaleChecked } from '../context/ScaleContext';
|
|
5
|
+
import useActiveSpectrumStyleOptions from '../hooks/useActiveSpectrumStyleOptions';
|
|
7
6
|
import useXYReduce, { XYReducerDomainAxis } from '../hooks/useXYReduce';
|
|
7
|
+
import { PathBuilder } from '../utility/PathBuilder';
|
|
8
8
|
import getVerticalShift from './utilities/getVerticalShift';
|
|
9
9
|
function Line({ data, id, display, index }) {
|
|
10
|
-
const {
|
|
11
|
-
const preferences = usePreferences();
|
|
10
|
+
const { verticalAlign } = useChartData();
|
|
12
11
|
const { scaleX, scaleY } = useScaleChecked();
|
|
13
12
|
const xyReduce = useXYReduce(XYReducerDomainAxis.XAxis);
|
|
14
|
-
const
|
|
15
|
-
return activeSpectrum === null
|
|
16
|
-
? true
|
|
17
|
-
: id === activeSpectrum.id
|
|
18
|
-
? true
|
|
19
|
-
: false;
|
|
20
|
-
}, [activeSpectrum, id]);
|
|
13
|
+
const { opacity } = useActiveSpectrumStyleOptions(id);
|
|
21
14
|
const vAlign = useMemo(() => {
|
|
22
15
|
return getVerticalShift(verticalAlign, { index });
|
|
23
16
|
}, [index, verticalAlign]);
|
|
24
17
|
const paths = useMemo(() => {
|
|
25
18
|
const _scaleX = scaleX();
|
|
26
19
|
const _scaleY = scaleY(id);
|
|
20
|
+
const pathBuilder = new PathBuilder();
|
|
27
21
|
if (data?.x && data?.y && _scaleX(0)) {
|
|
28
22
|
const pathPoints = xyReduce(data);
|
|
29
|
-
|
|
30
|
-
let
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
accumulator += ` L ${_scaleX(point)} ${_scaleY(pathPoints.y[i + 1])}`;
|
|
35
|
-
return accumulator;
|
|
36
|
-
}, '');
|
|
37
|
-
return path;
|
|
23
|
+
pathBuilder.moveTo(_scaleX(pathPoints.x[0]), _scaleY(pathPoints.y[0]));
|
|
24
|
+
for (let i = 1; i < pathPoints.x.length; i++) {
|
|
25
|
+
pathBuilder.lineTo(_scaleX(pathPoints.x[i]), _scaleY(pathPoints.y[i]));
|
|
26
|
+
}
|
|
27
|
+
return pathBuilder.toString();
|
|
38
28
|
}
|
|
39
29
|
else {
|
|
40
30
|
return '';
|
|
41
31
|
}
|
|
42
32
|
}, [scaleX, scaleY, id, data, xyReduce]);
|
|
43
33
|
return (_jsx("path", { className: "line", "data-test-id": "spectrum-line", stroke: display.color, fill: "none", style: {
|
|
44
|
-
opacity
|
|
45
|
-
? 1
|
|
46
|
-
: get(preferences, 'controllers.dimmedSpectraTransparency', 0.1),
|
|
34
|
+
opacity,
|
|
47
35
|
}, d: paths, transform: `translate(0,-${vAlign})` }, id));
|
|
48
36
|
}
|
|
49
37
|
export default Line;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { xGetFromToIndex } from 'ml-spectra-processing';
|
|
2
3
|
import { useCallback, useEffect, useReducer } from 'react';
|
|
3
4
|
import { ResponsiveChart } from 'react-d3-utils';
|
|
5
|
+
import { MAX_LENGTH } from '../../data/data1d/Spectrum1D/ranges/detectSignal';
|
|
4
6
|
import { ViewerResponsiveWrapper } from '../2d/Viewer2D';
|
|
5
7
|
import { BrushTracker } from '../EventsTrackers/BrushTracker';
|
|
6
8
|
import { MouseTracker } from '../EventsTrackers/MouseTracker';
|
|
@@ -8,10 +10,12 @@ import { useChartData } from '../context/ChartContext';
|
|
|
8
10
|
import { useDispatch } from '../context/DispatchContext';
|
|
9
11
|
import { usePreferences } from '../context/PreferencesContext';
|
|
10
12
|
import { ScaleProvider } from '../context/ScaleContext';
|
|
13
|
+
import { useAlert } from '../elements/popup/Alert';
|
|
11
14
|
import { useModal } from '../elements/popup/Modal';
|
|
12
15
|
import Spinner from '../loader/Spinner';
|
|
13
16
|
import MultipletAnalysisModal from '../modal/MultipletAnalysisModal';
|
|
14
17
|
import { ZoomType } from '../reducer/actions/Zoom';
|
|
18
|
+
import getRange from '../reducer/helper/getRange';
|
|
15
19
|
import scaleReducer, { scaleInitialState, SET_SCALE, } from '../reducer/scaleReducer';
|
|
16
20
|
import { ADD_INTEGRAL, ADD_PEAKS, ADD_BASE_LINE_ZONE, BRUSH_END, FULL_ZOOM_OUT, SET_ZOOM_FACTOR, ADD_PEAK, SET_VERTICAL_INDICATOR_X_POSITION, ADD_RANGE, ANALYZE_SPECTRA, ADD_EXCLUSION_ZONE, } from '../reducer/types/Types';
|
|
17
21
|
import BrushXY, { BRUSH_TYPE } from '../tool/BrushXY';
|
|
@@ -30,6 +34,7 @@ function Viewer1D({ emptyText = undefined }) {
|
|
|
30
34
|
const { toolOptions: { selectedTool }, isLoading, data, mode, width: widthProp, height: heightProp, margin, activeSpectrum, xDomain, xDomains, yDomain, yDomains, verticalAlign, displayerKey, } = state;
|
|
31
35
|
const dispatch = useDispatch();
|
|
32
36
|
const modal = useModal();
|
|
37
|
+
const alert = useAlert();
|
|
33
38
|
const [scaleState, dispatchScale] = useReducer(scaleReducer, scaleInitialState);
|
|
34
39
|
useEffect(() => {
|
|
35
40
|
if (xDomain.length > 0 && yDomain.length > 0 && widthProp && heightProp) {
|
|
@@ -95,12 +100,28 @@ function Viewer1D({ emptyText = undefined }) {
|
|
|
95
100
|
...brushData,
|
|
96
101
|
});
|
|
97
102
|
break;
|
|
98
|
-
case options.rangesPicking.id:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
case options.rangesPicking.id: {
|
|
104
|
+
const [from, to] = getRange(state, {
|
|
105
|
+
startX: brushData.startX,
|
|
106
|
+
endX: brushData.endX,
|
|
102
107
|
});
|
|
108
|
+
if (!activeSpectrum)
|
|
109
|
+
break;
|
|
110
|
+
const { data: { x }, } = state.data[activeSpectrum.index];
|
|
111
|
+
const { fromIndex, toIndex } = xGetFromToIndex(x, { from, to });
|
|
112
|
+
if (toIndex - fromIndex <= MAX_LENGTH) {
|
|
113
|
+
dispatch({
|
|
114
|
+
type: ADD_RANGE,
|
|
115
|
+
payload: {
|
|
116
|
+
...brushData,
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
alert.error(`Advanced peak picking only available for area up to ${MAX_LENGTH} points`);
|
|
122
|
+
}
|
|
103
123
|
break;
|
|
124
|
+
}
|
|
104
125
|
case options.multipleSpectraAnalysis.id:
|
|
105
126
|
dispatch({
|
|
106
127
|
type: ANALYZE_SPECTRA,
|
|
@@ -139,7 +160,17 @@ function Viewer1D({ emptyText = undefined }) {
|
|
|
139
160
|
break;
|
|
140
161
|
}
|
|
141
162
|
}
|
|
142
|
-
}, [
|
|
163
|
+
}, [
|
|
164
|
+
scaleState,
|
|
165
|
+
selectedTool,
|
|
166
|
+
general.disableMultipletAnalysis,
|
|
167
|
+
modal,
|
|
168
|
+
data,
|
|
169
|
+
activeSpectrum,
|
|
170
|
+
dispatch,
|
|
171
|
+
state,
|
|
172
|
+
alert,
|
|
173
|
+
]);
|
|
143
174
|
const handelOnDoubleClick = useCallback(() => {
|
|
144
175
|
dispatch({ type: FULL_ZOOM_OUT, zoomType: ZoomType.STEP_HORIZONTAL });
|
|
145
176
|
}, [dispatch]);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
2
|
-
import { memo } from 'react';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, memo } from 'react';
|
|
3
3
|
import { useChartData } from '../../context/ChartContext';
|
|
4
4
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
5
5
|
import Range from './Range';
|
|
6
6
|
import RangeIntegral from './RangeIntegral';
|
|
7
7
|
function RangesInner({ ranges, displayerKey, selectedTool, editRangeID, showMultiplicityTrees, showRangesIntegrals, }) {
|
|
8
|
-
return (_jsx("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, children: ranges?.values?.map((range) => (_jsxs(
|
|
8
|
+
return (_jsx("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, children: ranges?.values?.map((range) => (_jsxs(Fragment, { children: [_jsx(Range, { rangeData: range, selectedTool: selectedTool, showMultiplicityTrees: showMultiplicityTrees, startEditMode: editRangeID && editRangeID === range.id ? true : false }, void 0), showRangesIntegrals && _jsx(RangeIntegral, { range: range }, void 0)] }, range.id))) }, void 0));
|
|
9
9
|
}
|
|
10
10
|
const MemoizedRanges = memo(RangesInner);
|
|
11
11
|
const empyData = { ranges: {} };
|
|
File without changes
|
|
@@ -2,11 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/reac
|
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { useCallback, useMemo } from 'react';
|
|
5
|
-
import { useChartData } from '
|
|
6
|
-
import { useDispatch } from '
|
|
7
|
-
import { useScaleChecked } from '
|
|
8
|
-
import DeleteButton from '
|
|
9
|
-
import { DELETE_BASE_LINE_ZONE } from '
|
|
5
|
+
import { useChartData } from '../../context/ChartContext';
|
|
6
|
+
import { useDispatch } from '../../context/DispatchContext';
|
|
7
|
+
import { useScaleChecked } from '../../context/ScaleContext';
|
|
8
|
+
import DeleteButton from '../../elements/DeleteButton';
|
|
9
|
+
import { DELETE_BASE_LINE_ZONE } from '../../reducer/types/Types';
|
|
10
10
|
const styles = css `
|
|
11
11
|
pointer-events: bounding-box;
|
|
12
12
|
user-select: 'none';
|
|
@@ -2,6 +2,7 @@ import { xyIntegral, xyReduce } from 'ml-spectra-processing';
|
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { useChartData } from '../../context/ChartContext';
|
|
4
4
|
import { useScale } from '../../context/ScaleContext';
|
|
5
|
+
import { PathBuilder } from '../../utility/PathBuilder';
|
|
5
6
|
import { getYScale, reScaleY } from './scale';
|
|
6
7
|
export default function useIntegralPath(integralOptions) {
|
|
7
8
|
const { xDomain, height, yDomain, margin, verticalAlign, data, activeSpectrum, zoom, } = useChartData();
|
|
@@ -39,26 +40,24 @@ export default function useIntegralPath(integralOptions) {
|
|
|
39
40
|
}
|
|
40
41
|
return { x: [], y: [] };
|
|
41
42
|
}, [activeSpectrum, data, integralOptions]);
|
|
42
|
-
const
|
|
43
|
+
const paths = useMemo(() => {
|
|
43
44
|
if (integral && scaleX) {
|
|
44
|
-
// @ts-expect-error Types will be fixed in ml-spectra-processing.
|
|
45
45
|
const xySeries = xyReduce(integral, {
|
|
46
46
|
from: xDomain[0],
|
|
47
47
|
to: xDomain[1],
|
|
48
48
|
nbPoints: 200,
|
|
49
49
|
optimize: true,
|
|
50
50
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return path;
|
|
51
|
+
const pathBuilder = new PathBuilder();
|
|
52
|
+
pathBuilder.moveTo(scaleX()(xySeries.x[0]), scaleY(xySeries.y[0]));
|
|
53
|
+
for (let i = 1; i < xySeries.x.length; i++) {
|
|
54
|
+
pathBuilder.lineTo(scaleX()(xySeries.x[i]), scaleY(xySeries.y[i]));
|
|
55
|
+
}
|
|
56
|
+
return pathBuilder.toString();
|
|
58
57
|
}
|
|
59
58
|
else {
|
|
60
59
|
return '';
|
|
61
60
|
}
|
|
62
61
|
}, [integral, scaleX, scaleY, xDomain]);
|
|
63
|
-
return
|
|
62
|
+
return paths;
|
|
64
63
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import get from 'lodash/get';
|
|
3
3
|
import { memo, useMemo } from 'react';
|
|
4
|
+
import { getShift } from '../../data/data2d/Spectrum2D';
|
|
4
5
|
import { useChartData } from '../context/ChartContext';
|
|
5
6
|
import { usePreferences } from '../context/PreferencesContext';
|
|
7
|
+
import { PathBuilder } from '../utility/PathBuilder';
|
|
6
8
|
import { get2DXScale, get2DYScale } from './utilities/scale';
|
|
7
|
-
function ContoursPaths({ id: spectrumID, sign, color }) {
|
|
9
|
+
function ContoursPaths({ id: spectrumID, sign, color, datum, }) {
|
|
8
10
|
const { margin, width, height, xDomain, yDomain, contours, activeSpectrum } = useChartData();
|
|
9
11
|
const preferences = usePreferences();
|
|
12
|
+
const { xShift, yShift } = getShift(datum);
|
|
10
13
|
const isActive = useMemo(() => {
|
|
11
14
|
return activeSpectrum === null
|
|
12
15
|
? true
|
|
@@ -17,28 +20,26 @@ function ContoursPaths({ id: spectrumID, sign, color }) {
|
|
|
17
20
|
function buildContourPath(data) {
|
|
18
21
|
const _scaleX = get2DXScale({ margin, width, xDomain });
|
|
19
22
|
const _scaleY = get2DYScale({ margin, height, yDomain });
|
|
20
|
-
|
|
23
|
+
const path = new PathBuilder();
|
|
21
24
|
for (const element of data) {
|
|
22
25
|
if (element.lines) {
|
|
23
26
|
const lines = element.lines;
|
|
24
27
|
if (lines.length < 1e6) {
|
|
25
28
|
for (let i = 0; i < lines.length; i += 4) {
|
|
26
|
-
path
|
|
27
|
-
path
|
|
29
|
+
path.moveTo(_scaleX(lines[i] + xShift), _scaleY(lines[i + 1] + yShift));
|
|
30
|
+
path.lineTo(_scaleX(lines[i + 2] + xShift), _scaleY(lines[i + 3] + yShift));
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
else {
|
|
32
|
-
path
|
|
35
|
+
path.moveTo(_scaleX(element[0].x + xShift), _scaleY(element[0].y + yShift));
|
|
33
36
|
for (let j = 1; j < element.length; j++) {
|
|
34
|
-
path
|
|
37
|
+
path.lineTo(_scaleX(element[j].x + xShift), _scaleY(element[j].y + yShift));
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
path += 'Z';
|
|
41
|
-
return path;
|
|
41
|
+
path.closePath();
|
|
42
|
+
return path.toString();
|
|
42
43
|
}
|
|
43
44
|
const data = useMemo(() => {
|
|
44
45
|
return get(contours, `${spectrumID}.${sign}`, []);
|
|
@@ -50,7 +51,7 @@ function ContoursPaths({ id: spectrumID, sign, color }) {
|
|
|
50
51
|
}, d: buildContourPath(data) }, void 0));
|
|
51
52
|
}
|
|
52
53
|
function ContoursInner({ data, displayerKey }) {
|
|
53
|
-
return (_jsx("g", { clipPath: `url(#${displayerKey}clip-chart-2d)`, className: "contours", children: data?.map((datum, index) => (_jsxs("g", { children: [datum.display.isPositiveVisible && (_jsx(ContoursPaths, { id: datum.id, sign: "positive", color: datum.display.positiveColor }, void 0)), datum.display.isNegativeVisible && (_jsx(ContoursPaths, { id: datum.id, sign: "negative", color: datum.display.negativeColor }, void 0))] }, `${datum.id + index}`))) }, void 0));
|
|
54
|
+
return (_jsx("g", { clipPath: `url(#${displayerKey}clip-chart-2d)`, className: "contours", children: data?.map((datum, index) => (_jsxs("g", { children: [datum.display.isPositiveVisible && (_jsx(ContoursPaths, { id: datum.id, sign: "positive", datum: datum, color: datum.display.positiveColor }, void 0)), datum.display.isNegativeVisible && (_jsx(ContoursPaths, { id: datum.id, sign: "negative", datum: datum, color: datum.display.negativeColor }, void 0))] }, `${datum.id + index}`))) }, void 0));
|
|
54
55
|
}
|
|
55
56
|
const MemoizedContours = memo(ContoursInner);
|
|
56
57
|
export default function Contours() {
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo, memo } from 'react';
|
|
3
3
|
import { useChartData } from '../context/ChartContext';
|
|
4
4
|
import useXYReduce, { XYReducerDomainAxis } from '../hooks/useXYReduce';
|
|
5
|
+
import { PathBuilder } from '../utility/PathBuilder';
|
|
5
6
|
import { get1DYScale, get2DYScale } from './utilities/scale';
|
|
6
7
|
function Left1DChart({ margin: marignValue = 10, data: spectrum, }) {
|
|
7
8
|
const { height: originHeight, margin, yDomain, yDomains, displayerKey, } = useChartData();
|
|
@@ -17,15 +18,12 @@ function Left1DChart({ margin: marignValue = 10, data: spectrum, }) {
|
|
|
17
18
|
const scaleY = get1DYScale(yDomains[spectrum.id], height, marignValue);
|
|
18
19
|
const { x, re: y } = spectrum.data;
|
|
19
20
|
const pathPoints = xyReduce({ x, y });
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return accumulator;
|
|
27
|
-
}, '');
|
|
28
|
-
return path;
|
|
21
|
+
const pathBuilder = new PathBuilder();
|
|
22
|
+
pathBuilder.moveTo(scaleY(pathPoints.y[pathPoints.y.length - 1]), scaleX(pathPoints.x.length - 1));
|
|
23
|
+
for (let i = pathPoints.x.length - 2; i >= 0; i--) {
|
|
24
|
+
pathBuilder.lineTo(scaleY(pathPoints.y[i]), scaleX(pathPoints.x[i]));
|
|
25
|
+
}
|
|
26
|
+
return pathBuilder.toString();
|
|
29
27
|
}
|
|
30
28
|
else {
|
|
31
29
|
return undefined;
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo, memo } from 'react';
|
|
3
3
|
import { useChartData } from '../context/ChartContext';
|
|
4
4
|
import useXYReduce, { XYReducerDomainAxis } from '../hooks/useXYReduce';
|
|
5
|
+
import { PathBuilder } from '../utility/PathBuilder';
|
|
5
6
|
import { get1DYScale, get2DXScale } from './utilities/scale';
|
|
6
7
|
function Top1DChart({ margin: marginProps = 10, data: spectrum, }) {
|
|
7
8
|
const { width, margin: originMargin, xDomain, yDomains, displayerKey, } = useChartData();
|
|
@@ -13,13 +14,12 @@ function Top1DChart({ margin: marginProps = 10, data: spectrum, }) {
|
|
|
13
14
|
const scaleY = get1DYScale(yDomains[spectrum.id], height, marginProps);
|
|
14
15
|
const { x, re: y } = spectrum.data;
|
|
15
16
|
const pathPoints = xyReduce({ x, y });
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return path;
|
|
17
|
+
const pathBuilder = new PathBuilder();
|
|
18
|
+
pathBuilder.moveTo(scaleX(pathPoints.x[0]), scaleY(pathPoints.y[0]));
|
|
19
|
+
for (let i = 1; i < pathPoints.x.length; i++) {
|
|
20
|
+
pathBuilder.lineTo(scaleX(pathPoints.x[i]), scaleY(pathPoints.y[i]));
|
|
21
|
+
}
|
|
22
|
+
return pathBuilder.toString();
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
25
|
return undefined;
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo, memo } from 'react';
|
|
3
3
|
import { useChartData } from '../../../context/ChartContext';
|
|
4
4
|
import useXYReduce, { XYReducerDomainAxis } from '../../../hooks/useXYReduce';
|
|
5
|
+
import { PathBuilder } from '../../../utility/PathBuilder';
|
|
5
6
|
import { get2DXScale } from '../../utilities/scale';
|
|
6
7
|
import { getYScale } from './SliceScale';
|
|
7
8
|
function HorizontalSliceChart({ margin: marginProps = 10, data, }) {
|
|
@@ -14,13 +15,12 @@ function HorizontalSliceChart({ margin: marginProps = 10, data, }) {
|
|
|
14
15
|
const scaleX = get2DXScale({ margin: originMargin, width, xDomain });
|
|
15
16
|
const scaleY = getYScale(height, y, marginProps);
|
|
16
17
|
const pathPoints = xyReduce({ x, y });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return path;
|
|
18
|
+
const pathBuilder = new PathBuilder();
|
|
19
|
+
pathBuilder.moveTo(scaleX(pathPoints.x[0]), scaleY(pathPoints.y[0]));
|
|
20
|
+
for (let i = 1; i < pathPoints.x.length; i++) {
|
|
21
|
+
pathBuilder.lineTo(scaleX(pathPoints.x[i]), scaleY(pathPoints.y[i]));
|
|
22
|
+
}
|
|
23
|
+
return pathBuilder.toString();
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
26
|
return undefined;
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo, memo } from 'react';
|
|
3
3
|
import { useChartData } from '../../../context/ChartContext';
|
|
4
4
|
import useXYReduce, { XYReducerDomainAxis } from '../../../hooks/useXYReduce';
|
|
5
|
+
import { PathBuilder } from '../../../utility/PathBuilder';
|
|
5
6
|
import { get2DYScale } from '../../utilities/scale';
|
|
6
7
|
import { getYScale } from './SliceScale';
|
|
7
8
|
function VerticalSliceChart({ margin: marignValue = 10, data, }) {
|
|
@@ -14,15 +15,12 @@ function VerticalSliceChart({ margin: marignValue = 10, data, }) {
|
|
|
14
15
|
const scaleX = get2DYScale({ height: originHeight, margin, yDomain });
|
|
15
16
|
const scaleY = getYScale(height, y, marignValue);
|
|
16
17
|
const pathPoints = xyReduce({ x, y });
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return accumulator;
|
|
24
|
-
}, '');
|
|
25
|
-
return path;
|
|
18
|
+
const pathBuilder = new PathBuilder();
|
|
19
|
+
pathBuilder.moveTo(scaleY(pathPoints.y[pathPoints.y.length - 1]), scaleX(pathPoints.x.length - 1));
|
|
20
|
+
for (let i = pathPoints.x.length - 2; i >= 0; i--) {
|
|
21
|
+
pathBuilder.lineTo(scaleY(pathPoints.y[i]), scaleX(pathPoints.x[i]));
|
|
22
|
+
}
|
|
23
|
+
return pathBuilder.toString();
|
|
26
24
|
}
|
|
27
25
|
else {
|
|
28
26
|
return undefined;
|
|
@@ -66,8 +66,8 @@ export function BrushTracker({ children, className, style, onBrush = () => null,
|
|
|
66
66
|
onZoom({ deltaY: deltaY || deltaX, shiftKey, deltaMode, x, y });
|
|
67
67
|
}, [onZoom]);
|
|
68
68
|
useEffect(() => {
|
|
69
|
-
const { step, startX, endX } = state;
|
|
70
|
-
if (step === 'end' && Math.
|
|
69
|
+
const { step, startX, endX, startY, endY } = state;
|
|
70
|
+
if (step === 'end' && Math.hypot(endX - startX, endY - startY) > 5) {
|
|
71
71
|
onBrush(state);
|
|
72
72
|
dispatch({
|
|
73
73
|
type: 'DONE',
|
|
@@ -26,7 +26,7 @@ function KeysListenerTracker() {
|
|
|
26
26
|
const allow2DTool = useMemo(() => {
|
|
27
27
|
return displayerMode === DISPLAYER_MODE.DM_2D && data && data.length > 0;
|
|
28
28
|
}, [data, displayerMode]);
|
|
29
|
-
const deleteHandler = useCallback((sourceData) => {
|
|
29
|
+
const deleteHandler = useCallback(async (sourceData) => {
|
|
30
30
|
const { type, extra: { id }, } = sourceData;
|
|
31
31
|
switch (type) {
|
|
32
32
|
case HighlightedSource.INTEGRAL: {
|
|
@@ -74,12 +74,15 @@ function KeysListenerTracker() {
|
|
|
74
74
|
break;
|
|
75
75
|
}
|
|
76
76
|
case HighlightedSource.EXCLUSION_ZONE: {
|
|
77
|
+
const hideLoading = await alert.showLoading(`Exclusion filter in progress`);
|
|
77
78
|
dispatch({
|
|
78
79
|
type: DELETE_EXCLUSION_ZONE,
|
|
79
80
|
payload: {
|
|
80
81
|
id,
|
|
82
|
+
spectrumID: sourceData.extra.spectrumID,
|
|
81
83
|
},
|
|
82
84
|
});
|
|
85
|
+
hideLoading();
|
|
83
86
|
// remove keys from the highlighted list after delete
|
|
84
87
|
remove();
|
|
85
88
|
break;
|
|
@@ -87,7 +90,7 @@ function KeysListenerTracker() {
|
|
|
87
90
|
default:
|
|
88
91
|
break;
|
|
89
92
|
}
|
|
90
|
-
}, [assignmentData, dispatch, remove]);
|
|
93
|
+
}, [assignmentData, dispatch, remove, alert]);
|
|
91
94
|
const keysPreferencesListenerHandler = useCallback((e, num) => {
|
|
92
95
|
if (data && data.length > 0 && num >= 1 && num <= 9) {
|
|
93
96
|
if (e.shiftKey) {
|
|
@@ -159,6 +162,12 @@ function KeysListenerTracker() {
|
|
|
159
162
|
}
|
|
160
163
|
break;
|
|
161
164
|
}
|
|
165
|
+
case 'e': {
|
|
166
|
+
if (allow1DTool) {
|
|
167
|
+
handleChangeOption(options.exclusionZones.id);
|
|
168
|
+
}
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
162
171
|
default:
|
|
163
172
|
}
|
|
164
173
|
}
|
|
@@ -228,7 +237,7 @@ function KeysListenerTracker() {
|
|
|
228
237
|
else {
|
|
229
238
|
if (['Delete', 'Backspace'].includes(e.key) && highlight.sourceData) {
|
|
230
239
|
e.preventDefault();
|
|
231
|
-
deleteHandler(highlight.sourceData);
|
|
240
|
+
void deleteHandler(highlight.sourceData);
|
|
232
241
|
}
|
|
233
242
|
else {
|
|
234
243
|
toolsListenerHandler(e);
|
|
@@ -66,6 +66,6 @@ export interface NMRiumData {
|
|
|
66
66
|
molecules?: Molecules;
|
|
67
67
|
spectra: DeepPartial<Spectra>;
|
|
68
68
|
}
|
|
69
|
-
declare function NMRium(
|
|
69
|
+
declare function NMRium(props: NMRiumProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
70
70
|
declare const _default: import("react").MemoExoticComponent<typeof NMRium>;
|
|
71
71
|
export default _default;
|