nmrium 0.47.0 → 0.49.0
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 +1 -1
- package/lib/component/1d/Line.js +1 -1
- package/lib/component/1d/LinesSeries.d.ts +1 -1
- package/lib/component/1d/LinesSeries.js +24 -3
- package/lib/component/1d/SpectraLegends.js +1 -1
- package/lib/component/1d/Viewer1D.js +144 -124
- package/lib/component/1d/jCouplingGraph/JsCoupling.js +1 -1
- package/lib/component/1d/peaks/Peaks.js +5 -4
- package/lib/component/1d/ranges/Atoms.d.ts +7 -0
- package/lib/component/1d/ranges/Atoms.js +43 -0
- package/lib/component/1d/ranges/Range.js +4 -2
- package/lib/component/1d/tool/BaseLine.d.ts +2 -0
- package/lib/component/1d/tool/BaseLine.js +26 -0
- package/lib/component/1d/tool/BaseLineZones.js +18 -3
- package/lib/component/1d/utilities/scale.d.ts +1 -0
- package/lib/component/1d/utilities/scale.js +2 -1
- package/lib/component/2d/Chart2D.js +6 -4
- package/lib/component/2d/Viewer2D.js +35 -26
- package/lib/component/context/KeyModifierContext.d.ts +14 -3
- package/lib/component/context/KeyModifierContext.js +35 -4
- package/lib/component/context/LoggerContext.d.ts +9 -0
- package/lib/component/context/LoggerContext.js +21 -7
- package/lib/component/context/PreferencesContext.d.ts +1 -108
- package/lib/component/context/TopicMoleculeContext.d.ts +8 -0
- package/lib/component/context/TopicMoleculeContext.js +30 -0
- package/lib/component/elements/Input.js +4 -1
- package/lib/component/elements/ResizerWithScale.js +19 -2
- package/lib/component/elements/SVGGroup.js +2 -2
- package/lib/component/elements/formik/FormikTextarea.js +8 -9
- package/lib/component/elements/linearAxis/LinearVerticalAxis.js +1 -1
- package/lib/component/elements/resizer/SVGResizer.js +1 -1
- package/lib/component/header/BaseLineCorrectionPanel.js +3 -2
- package/lib/component/header/Header.js +2 -2
- package/lib/component/hooks/useCheckToolsVisibility.js +1 -1
- package/lib/component/hooks/useExport.js +2 -2
- package/lib/component/hooks/useSetActiveSpectrumAction.d.ts +3 -0
- package/lib/component/hooks/useSetActiveSpectrumAction.js +16 -0
- package/lib/component/hooks/useToolsFunctions.js +4 -2
- package/lib/component/hooks/useVerticalAlign.d.ts +1 -1
- package/lib/component/main/InnerNMRium.js +3 -2
- package/lib/component/modal/ExportAsJcampModal.js +1 -1
- package/lib/component/modal/ImportPublicationStringModal.d.ts +2 -1
- package/lib/component/modal/ImportPublicationStringModal.js +76 -32
- package/lib/component/modal/editRange/forms/validation/EditRangeValidation.js +2 -4
- package/lib/component/modal/setting/settings-tabs/GeneralTabContent.js +9 -11
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +2 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts +2 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -5
- package/lib/component/panels/RangesPanel/RangesTable.js +1 -1
- package/lib/component/panels/SpectrumsPanel/SpectraPreferences.js +39 -5
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +28 -40
- package/lib/component/panels/SpectrumsPanel/SpectrumListPanel.js +4 -2
- package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.js +3 -9
- package/lib/component/panels/SpectrumsPanel/base/RenderAsHTML.d.ts +7 -0
- package/lib/component/panels/SpectrumsPanel/base/RenderAsHTML.js +21 -0
- package/lib/component/panels/SpectrumsPanel/base/SpectraColumnsManager.js +19 -16
- package/lib/component/panels/SpectrumsPanel/base/SpectrumName.js +0 -1
- package/lib/component/panels/databasePanel/DatabasePanel.js +6 -1
- package/lib/component/panels/multipleAnalysisPanel/AnalysisChart.js +1 -1
- package/lib/component/panels/predictionPanel/PredictionPanel.js +3 -1
- package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +15 -4
- package/lib/component/reducer/Reducer.js +2 -0
- package/lib/component/reducer/actions/DomainActions.d.ts +2 -2
- package/lib/component/reducer/actions/DomainActions.js +2 -2
- package/lib/component/reducer/actions/FiltersActions.d.ts +3 -4
- package/lib/component/reducer/actions/FiltersActions.js +93 -57
- package/lib/component/reducer/actions/LoadActions.js +10 -8
- package/lib/component/reducer/actions/SpectrumsActions.d.ts +8 -1
- package/lib/component/reducer/actions/SpectrumsActions.js +8 -4
- package/lib/component/reducer/actions/ToolsActions.d.ts +8 -5
- package/lib/component/reducer/actions/ToolsActions.js +51 -44
- package/lib/component/reducer/helper/getVerticalAlign.d.ts +1 -1
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +0 -4
- package/lib/component/toolbar/BasicToolBar.js +11 -29
- package/lib/component/utility/export.d.ts +3 -2
- package/lib/component/utility/export.js +45 -26
- package/lib/component/workspaces/exercise.js +1 -0
- package/lib/component/workspaces/prediction.js +1 -16
- package/lib/component/workspaces/simulation.js +1 -2
- package/lib/component/workspaces/workspaceDefaultProperties.js +4 -3
- package/lib/data/data1d/Spectrum1D/index.d.ts +0 -1
- package/lib/data/data1d/Spectrum1D/index.js +0 -1
- package/lib/data/data1d/multipleSpectraAnalysis.js +27 -40
- package/lib/data/data2d/Spectrum2D/getMissingProjection.js +10 -1
- package/lib/versionInfo.js +1 -1
- package/package.json +31 -30
- package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.d.ts +0 -2
- package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.js +0 -6
|
@@ -20,6 +20,6 @@ function Chart1D({ mode, width, height, margin, displayerKey }) {
|
|
|
20
20
|
const { current: { general: { spectraRendering }, }, } = usePreferences();
|
|
21
21
|
const innerWidth = width - margin.left - margin.right;
|
|
22
22
|
const innerHeight = height - margin.bottom;
|
|
23
|
-
return (_jsx(PeakEditionProvider, { children: _jsxs("svg", { viewBox: `0 0 ${width} ${height}`,
|
|
23
|
+
return (_jsx(PeakEditionProvider, { children: _jsxs("svg", { id: "nmrSVG", width: width, height: height, viewBox: `0 0 ${width} ${height}`, fontFamily: "Arial, Helvetica, sans-serif", shapeRendering: spectraRendering, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-chart-1d`, children: _jsx("rect", { width: innerWidth, height: innerHeight, x: margin.left, y: "0" }) }) }), _jsx(LinesSeries, {}), _jsx(ApodizationLine, {}), _jsx(IntegralsSeries, {}), _jsx(Peaks, { peaksSource: "peaks" }), _jsx(RangesIntegrals, {}), _jsx(Peaks, { peaksSource: "ranges" }), _jsx(Ranges, {}), _jsx(JGraph, {}), _jsx(MultiAnalysisRanges, {}), _jsx(BaseLineZones, {}), _jsx(ExclusionZonesAnnotations, {}), _jsx(DatabaseElements, {}), _jsx(PeaksShapes, {}), _jsx(SpectraTracker, {}), _jsx(SpectrumInfoBlock, {}), _jsx("g", { className: "container", style: { pointerEvents: 'none' }, children: _jsx(XAxis, { showGrid: true, mode: mode }) })] }) }));
|
|
24
24
|
}
|
|
25
25
|
export default Chart1D;
|
package/lib/component/1d/Line.js
CHANGED
|
@@ -26,6 +26,6 @@ function Line({ data, id, display, index }) {
|
|
|
26
26
|
}
|
|
27
27
|
}, [scaleX, scaleY, id, data, xyReduce]);
|
|
28
28
|
const { color: stroke, opacity: strokeOpacity } = parseColor(display?.color || 'black');
|
|
29
|
-
return (_jsx("path", { className: "line", "data-testid": "spectrum-line", stroke: stroke, fill: "none", strokeOpacity: opacity === 1 ? strokeOpacity : opacity, d: paths, transform: `translate(0,-${shiftY * index})` }
|
|
29
|
+
return (_jsx("path", { id: id, className: "line", "data-testid": "spectrum-line", stroke: stroke, fill: "none", strokeOpacity: opacity === 1 ? strokeOpacity : opacity, d: paths, transform: `translate(0,-${shiftY * index})` }));
|
|
30
30
|
}
|
|
31
31
|
export default Line;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function LinesSeries(): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
declare function LinesSeries(): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
2
2
|
export default LinesSeries;
|
|
@@ -1,13 +1,34 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { css } from '@emotion/react';
|
|
2
4
|
import { get1DDataXY } from '../../data/data1d/Spectrum1D/get1DDataXY';
|
|
3
5
|
import { isSpectrum1D } from '../../data/data1d/Spectrum1D/isSpectrum1D';
|
|
4
6
|
import { useChartData } from '../context/ChartContext';
|
|
7
|
+
import { useScaleChecked } from '../context/ScaleContext';
|
|
5
8
|
import { useActiveSpectra } from '../hooks/useActiveSpectra';
|
|
9
|
+
import { useSetActiveSpectrumAction } from '../hooks/useSetActiveSpectrumAction';
|
|
10
|
+
import { useVerticalAlign } from '../hooks/useVerticalAlign';
|
|
6
11
|
import Line from './Line';
|
|
12
|
+
import { SPECTRA_BOTTOM_MARGIN } from './utilities/scale';
|
|
13
|
+
const BOX_SIZE = 10;
|
|
14
|
+
const style = css `
|
|
15
|
+
fill: transparent;
|
|
16
|
+
|
|
17
|
+
&:hover {
|
|
18
|
+
fill: #ff6f0057;
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
7
21
|
function LinesSeries() {
|
|
8
|
-
const { data, displayerKey, xDomains } = useChartData();
|
|
22
|
+
const { data, displayerKey, xDomains, width, margin, height } = useChartData();
|
|
9
23
|
const activeSpectra = useActiveSpectra();
|
|
24
|
+
const { shiftY } = useScaleChecked();
|
|
25
|
+
const verticalAlign = useVerticalAlign();
|
|
26
|
+
const innerWidth = width - margin.left - margin.right;
|
|
27
|
+
const innerHeight = height - margin.bottom - SPECTRA_BOTTOM_MARGIN;
|
|
10
28
|
const spectra = (data?.filter((d) => isSpectrum1D(d) && d.display.isVisible && xDomains[d.id]) || []);
|
|
11
|
-
|
|
29
|
+
const { setActiveSpectrum } = useSetActiveSpectrumAction();
|
|
30
|
+
return (_jsxs("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, className: "spectrums", children: [spectra.map((d, i) => (_jsxs("g", { children: [_jsx(Line, { display: d.display, id: d.id, data: get1DDataXY(d), index: i }), verticalAlign === 'stack' && (_jsx("rect", { css: style, y: innerHeight - shiftY * i - BOX_SIZE / 2, x: margin.left, width: `${innerWidth}px`, height: `${BOX_SIZE}px`, onClick: (e) => {
|
|
31
|
+
setActiveSpectrum(e, d.id);
|
|
32
|
+
} }))] }, d.id))), activeSpectra?.map((activeSpectrum) => (_jsx("use", { href: `#${activeSpectrum.id}` }, activeSpectrum.id)))] }));
|
|
12
33
|
}
|
|
13
34
|
export default LinesSeries;
|
|
@@ -31,7 +31,7 @@ function InnerSpectraLegends({ spectra, legendsFields, }) {
|
|
|
31
31
|
return (_jsx("g", { className: "spectra-intensity-legend", children: spectra.map((spectrum, index) => (_jsxs("g", { transform: `translate(5,${20 * (index + 1)})`, children: [_jsx("rect", { style: {
|
|
32
32
|
...styles.colorIndicator,
|
|
33
33
|
fill: spectrum.display.color,
|
|
34
|
-
} }), _jsx(SVGGroup, { space: 5,
|
|
34
|
+
} }), _jsx(SVGGroup, { space: 5, transform: "translate(12 0)", children: legendsFields.map((field) => {
|
|
35
35
|
const predefinedField = field;
|
|
36
36
|
switch (predefinedField?.name) {
|
|
37
37
|
case 'intensity':
|
|
@@ -9,6 +9,7 @@ import { BrushTracker, } from '../EventsTrackers/BrushTracker';
|
|
|
9
9
|
import { MouseTracker } from '../EventsTrackers/MouseTracker';
|
|
10
10
|
import { useChartData } from '../context/ChartContext';
|
|
11
11
|
import { useDispatch } from '../context/DispatchContext';
|
|
12
|
+
import { useMapKeyModifiers } from '../context/KeyModifierContext';
|
|
12
13
|
import { usePreferences } from '../context/PreferencesContext';
|
|
13
14
|
import { ScaleProvider } from '../context/ScaleContext';
|
|
14
15
|
import { useActiveSpectrum } from '../hooks/useActiveSpectrum';
|
|
@@ -22,6 +23,7 @@ import { options } from '../toolbar/ToolTypes';
|
|
|
22
23
|
import Events from '../utility/Events';
|
|
23
24
|
import Chart1D from './Chart1D';
|
|
24
25
|
import FooterBanner from './FooterBanner';
|
|
26
|
+
import BaseLine from './tool/BaseLine';
|
|
25
27
|
import PeakPointer from './tool/PeakPointer';
|
|
26
28
|
import VerticalIndicator from './tool/VerticalIndicator';
|
|
27
29
|
import XLabelPointer from './tool/XLabelPointer';
|
|
@@ -76,10 +78,12 @@ function Viewer1D({ emptyText = undefined }) {
|
|
|
76
78
|
}
|
|
77
79
|
const [isOpenAnalysisModal, openAnalysisModal, closeAnalysisModal] = useOnOff(false);
|
|
78
80
|
const [brushData, setBrushData] = useState(null);
|
|
81
|
+
const { getModifiersKey, primaryKeyIdentifier } = useMapKeyModifiers();
|
|
79
82
|
const handelBrushEnd = useCallback((brushData) => {
|
|
80
83
|
//reset the brush start
|
|
81
84
|
brushStartRef.current = null;
|
|
82
85
|
setBrushData(brushData);
|
|
86
|
+
const keyModifiers = getModifiersKey(brushData);
|
|
83
87
|
if (brushData.mouseButton === 'main') {
|
|
84
88
|
const propagateEvent = () => {
|
|
85
89
|
if (!scaleState.scaleX || !scaleState.scaleY)
|
|
@@ -92,109 +96,124 @@ function Viewer1D({ emptyText = undefined }) {
|
|
|
92
96
|
range: [startXPPM, endXPPM].sort((a, b) => a - b),
|
|
93
97
|
});
|
|
94
98
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
else if (brushData.shiftKey) {
|
|
106
|
-
switch (selectedTool) {
|
|
107
|
-
case options.integral.id:
|
|
108
|
-
dispatch({
|
|
109
|
-
type: 'ADD_INTEGRAL',
|
|
110
|
-
payload: brushData,
|
|
111
|
-
});
|
|
112
|
-
break;
|
|
113
|
-
case options.rangePicking.id: {
|
|
114
|
-
if (!activeSpectrum)
|
|
99
|
+
let executeDefaultAction = false;
|
|
100
|
+
switch (keyModifiers) {
|
|
101
|
+
// when Alt key is active
|
|
102
|
+
case primaryKeyIdentifier: {
|
|
103
|
+
switch (selectedTool) {
|
|
104
|
+
case options.zoom.id: {
|
|
105
|
+
executeDefaultAction = true;
|
|
115
106
|
break;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
107
|
+
}
|
|
108
|
+
case options.integral.id:
|
|
109
|
+
dispatch({
|
|
110
|
+
type: 'ADD_INTEGRAL',
|
|
111
|
+
payload: brushData,
|
|
112
|
+
});
|
|
113
|
+
break;
|
|
114
|
+
case options.rangePicking.id: {
|
|
115
|
+
if (!activeSpectrum)
|
|
116
|
+
break;
|
|
117
|
+
dispatch({
|
|
118
|
+
type: 'ADD_RANGE',
|
|
119
|
+
payload: brushData,
|
|
120
|
+
});
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
case options.multipleSpectraAnalysis.id:
|
|
124
|
+
if (scaleState.scaleX) {
|
|
125
|
+
const { startX, endX } = brushData;
|
|
126
|
+
const start = scaleState.scaleX().invert(startX);
|
|
127
|
+
const end = scaleState.scaleX().invert(endX);
|
|
128
|
+
dispatchPreferences({
|
|
129
|
+
type: 'ANALYZE_SPECTRA',
|
|
130
|
+
payload: {
|
|
131
|
+
start,
|
|
132
|
+
end,
|
|
133
|
+
nucleus: activeTab,
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
case options.peakPicking.id:
|
|
139
|
+
dispatch({
|
|
140
|
+
type: 'ADD_PEAKS',
|
|
141
|
+
payload: brushData,
|
|
142
|
+
});
|
|
143
|
+
break;
|
|
144
|
+
case options.baselineCorrection.id:
|
|
145
|
+
dispatch({
|
|
146
|
+
type: 'ADD_BASE_LINE_ZONE',
|
|
147
|
+
payload: {
|
|
148
|
+
startX: brushData.startX,
|
|
149
|
+
endX: brushData.endX,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
break;
|
|
153
|
+
case options.exclusionZones.id:
|
|
154
|
+
dispatch({
|
|
155
|
+
type: 'ADD_EXCLUSION_ZONE',
|
|
156
|
+
payload: { startX: brushData.startX, endX: brushData.endX },
|
|
157
|
+
});
|
|
158
|
+
break;
|
|
159
|
+
case options.matrixGenerationExclusionZones.id: {
|
|
160
|
+
const [from, to] = getRange(state, {
|
|
161
|
+
startX: brushData.startX,
|
|
162
|
+
endX: brushData.endX,
|
|
163
|
+
});
|
|
127
164
|
dispatchPreferences({
|
|
128
|
-
type: '
|
|
165
|
+
type: 'ADD_MATRIX_GENERATION_EXCLUSION_ZONE',
|
|
129
166
|
payload: {
|
|
130
|
-
|
|
131
|
-
end,
|
|
167
|
+
zone: { from, to },
|
|
132
168
|
nucleus: activeTab,
|
|
169
|
+
range: { from: xDomain[0], to: xDomain[1] },
|
|
133
170
|
},
|
|
134
171
|
});
|
|
172
|
+
break;
|
|
135
173
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
type: 'ADD_PEAKS',
|
|
140
|
-
payload: brushData,
|
|
141
|
-
});
|
|
142
|
-
break;
|
|
143
|
-
case options.baselineCorrection.id:
|
|
144
|
-
dispatch({
|
|
145
|
-
type: 'ADD_BASE_LINE_ZONE',
|
|
146
|
-
payload: {
|
|
147
|
-
startX: brushData.startX,
|
|
148
|
-
endX: brushData.endX,
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
break;
|
|
152
|
-
case options.exclusionZones.id:
|
|
153
|
-
dispatch({
|
|
154
|
-
type: 'ADD_EXCLUSION_ZONE',
|
|
155
|
-
payload: { startX: brushData.startX, endX: brushData.endX },
|
|
156
|
-
});
|
|
157
|
-
break;
|
|
158
|
-
case options.matrixGenerationExclusionZones.id: {
|
|
159
|
-
const [from, to] = getRange(state, {
|
|
160
|
-
startX: brushData.startX,
|
|
161
|
-
endX: brushData.endX,
|
|
162
|
-
});
|
|
163
|
-
dispatchPreferences({
|
|
164
|
-
type: 'ADD_MATRIX_GENERATION_EXCLUSION_ZONE',
|
|
165
|
-
payload: {
|
|
166
|
-
zone: { from, to },
|
|
167
|
-
nucleus: activeTab,
|
|
168
|
-
range: { from: xDomain[0], to: xDomain[1] },
|
|
169
|
-
},
|
|
170
|
-
});
|
|
171
|
-
break;
|
|
174
|
+
default:
|
|
175
|
+
propagateEvent();
|
|
176
|
+
break;
|
|
172
177
|
}
|
|
173
|
-
|
|
174
|
-
propagateEvent();
|
|
175
|
-
break;
|
|
178
|
+
break;
|
|
176
179
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
dispatch({ type: 'BRUSH_END', payload: brushData });
|
|
180
|
+
case 'shift[false]_ctrl[false]_alt[true]': {
|
|
181
|
+
switch (selectedTool) {
|
|
182
|
+
case options.rangePicking.id: {
|
|
183
|
+
openAnalysisModal();
|
|
184
|
+
break;
|
|
183
185
|
}
|
|
184
|
-
|
|
186
|
+
default:
|
|
187
|
+
executeDefaultAction = true;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
break;
|
|
185
191
|
}
|
|
192
|
+
default: {
|
|
193
|
+
executeDefaultAction = true;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const isNotDistanceMeasurementTool = selectedTool !== 'zoom' ||
|
|
198
|
+
(selectedTool === 'zoom' && !brushData.shiftKey);
|
|
199
|
+
if (executeDefaultAction &&
|
|
200
|
+
selectedTool != null &&
|
|
201
|
+
isNotDistanceMeasurementTool) {
|
|
202
|
+
dispatch({ type: 'BRUSH_END', payload: brushData });
|
|
186
203
|
}
|
|
187
204
|
}
|
|
188
205
|
}, [
|
|
189
|
-
|
|
206
|
+
getModifiersKey,
|
|
190
207
|
selectedTool,
|
|
191
|
-
|
|
192
|
-
|
|
208
|
+
scaleState,
|
|
209
|
+
primaryKeyIdentifier,
|
|
193
210
|
dispatch,
|
|
211
|
+
activeSpectrum,
|
|
194
212
|
dispatchPreferences,
|
|
195
213
|
activeTab,
|
|
196
|
-
xDomain,
|
|
197
214
|
state,
|
|
215
|
+
xDomain,
|
|
216
|
+
openAnalysisModal,
|
|
198
217
|
]);
|
|
199
218
|
const handelOnDoubleClick = useCallback(() => {
|
|
200
219
|
dispatch({
|
|
@@ -215,47 +234,48 @@ function Viewer1D({ emptyText = undefined }) {
|
|
|
215
234
|
xPPM,
|
|
216
235
|
});
|
|
217
236
|
};
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
default:
|
|
237
|
+
const keyModifiers = getModifiersKey(event);
|
|
238
|
+
switch (keyModifiers) {
|
|
239
|
+
case primaryKeyIdentifier: {
|
|
240
|
+
switch (selectedTool) {
|
|
241
|
+
case options.peakPicking.id:
|
|
242
|
+
dispatch({
|
|
243
|
+
type: 'ADD_PEAK',
|
|
244
|
+
payload: event,
|
|
245
|
+
});
|
|
246
|
+
break;
|
|
247
|
+
case options.editRange.id:
|
|
248
|
+
propagateEvent();
|
|
249
|
+
break;
|
|
250
|
+
case options.integral.id:
|
|
251
|
+
dispatch({
|
|
252
|
+
type: 'CUT_INTEGRAL',
|
|
253
|
+
payload: { cutValue: xPPM },
|
|
254
|
+
});
|
|
255
|
+
break;
|
|
256
|
+
case options.rangePicking.id:
|
|
257
|
+
dispatch({
|
|
258
|
+
type: 'CUT_RANGE',
|
|
259
|
+
payload: { cutValue: xPPM },
|
|
260
|
+
});
|
|
261
|
+
break;
|
|
262
|
+
case options.phaseCorrection.id:
|
|
263
|
+
dispatch({
|
|
264
|
+
type: 'SET_ONE_DIMENSION_PIVOT_POINT',
|
|
265
|
+
payload: {
|
|
266
|
+
value: event.x,
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
break;
|
|
270
|
+
default:
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
break;
|
|
256
274
|
}
|
|
275
|
+
default:
|
|
276
|
+
break;
|
|
257
277
|
}
|
|
258
|
-
}, [dispatch, scaleState, selectedTool]);
|
|
278
|
+
}, [dispatch, getModifiersKey, primaryKeyIdentifier, scaleState, selectedTool]);
|
|
259
279
|
return (_jsxs(ScaleProvider, { value: scaleState, children: [_jsx(ResponsiveChart, { children: ({ height, width }) => (_jsx(ViewerResponsiveWrapper, { height: height, width: width, children: _jsxs("div", { style: { height: '100%', position: 'relative' }, children: [_jsx(Spinner, { isLoading: isLoading, emptyText: emptyText }), scaleState.scaleX &&
|
|
260
280
|
scaleState.scaleY &&
|
|
261
281
|
data &&
|
|
@@ -269,6 +289,6 @@ function Viewer1D({ emptyText = undefined }) {
|
|
|
269
289
|
width: '100%',
|
|
270
290
|
height: `100%`,
|
|
271
291
|
position: 'absolute',
|
|
272
|
-
}, children: [_jsx(CrossLinePointer, {}), _jsx(BrushXY, { brushType: BRUSH_TYPE.X }), _jsx(XLabelPointer, {}), _jsx(PeakPointer, {}), _jsx(VerticalIndicator, {}), _jsx(FooterBanner, {}), _jsx(Chart1D, { width: widthProp, height: heightProp, margin: margin, mode: mode, displayerKey: displayerKey })] }) }))] }) })) }), brushData && (_jsx(MultipletAnalysisModal, { isOpen: isOpenAnalysisModal, onClose: closeAnalysisModal, data: data, activeSpectrum: activeSpectrum, scaleX: scaleState.scaleX, ...brushData }))] }));
|
|
292
|
+
}, children: [_jsx(CrossLinePointer, {}), _jsx(BrushXY, { brushType: BRUSH_TYPE.X }), _jsx(XLabelPointer, {}), _jsx(PeakPointer, {}), _jsx(VerticalIndicator, {}), _jsx(FooterBanner, {}), _jsx(Chart1D, { width: widthProp, height: heightProp, margin: margin, mode: mode, displayerKey: displayerKey }), _jsx(BaseLine, {})] }) }))] }) })) }), brushData && (_jsx(MultipletAnalysisModal, { isOpen: isOpenAnalysisModal, onClose: closeAnalysisModal, data: data, activeSpectrum: activeSpectrum, scaleX: scaleState.scaleX, ...brushData }))] }));
|
|
273
293
|
}
|
|
274
294
|
export default Viewer1D;
|
|
@@ -6,5 +6,5 @@ export default function JsCoupling({ value }) {
|
|
|
6
6
|
const [isOver, setOver] = useState(false);
|
|
7
7
|
if (!scaleY)
|
|
8
8
|
return null;
|
|
9
|
-
return (_jsxs("g", { className: "coupling",
|
|
9
|
+
return (_jsxs("g", { className: "coupling", transform: `translate(0 ${scaleY(value)})`, children: [_jsx("circle", { onMouseEnter: () => setOver(true), onMouseLeave: () => setOver(false), cx: 0, cy: 0, r: 4, fill: `hsl(${(value * 360) / maxValue},100%,${isOver ? 45 : 50}%)`, pointerEvents: "all" }), isOver && (_jsxs("g", { transform: "translate(0 15)", children: [_jsx("text", { pointerEvents: "none", stroke: "white", strokeWidth: "0.6em", fontSize: "11px", dominantBaseline: "middle", textAnchor: "end", children: `${value.toFixed(1)} Hz` }), _jsx("text", { pointerEvents: "none", stroke: "black", fontSize: "11px", dominantBaseline: "middle", textAnchor: "end", children: `${value.toFixed(1)} Hz` })] }))] }));
|
|
10
10
|
}
|
|
@@ -69,13 +69,14 @@ export default function Peaks(props) {
|
|
|
69
69
|
const { deltaPPM: { format: peakFormat }, } = usePanelPreferences(peaksSource === 'peaks' ? 'peaks' : 'ranges', nucleus);
|
|
70
70
|
const canDisplaySpectrumPeaks = !spectrum.display.isVisible || spectrum.info?.isFid;
|
|
71
71
|
let mode = 'spread';
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
if (peaksSource === 'peaks' &&
|
|
73
|
+
(spectrum.peaks?.values?.length === 0 ||
|
|
74
|
+
!peaksViewState.showPeaks ||
|
|
75
|
+
canDisplaySpectrumPeaks)) {
|
|
75
76
|
return null;
|
|
76
77
|
}
|
|
77
78
|
if (peaksSource === 'ranges' &&
|
|
78
|
-
(
|
|
79
|
+
(spectrum.ranges?.values?.length === 0 ||
|
|
79
80
|
!rangesViewState.showPeaks ||
|
|
80
81
|
canDisplaySpectrumPeaks)) {
|
|
81
82
|
return null;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useChartData } from '../../context/ChartContext';
|
|
3
|
+
import { useTopicMolecule } from '../../context/TopicMoleculeContext';
|
|
4
|
+
const fontSize = 12;
|
|
5
|
+
const lineHeight = fontSize * 1.1;
|
|
6
|
+
const marginTop = 55;
|
|
7
|
+
function getDiaIds(range) {
|
|
8
|
+
const { diaIDs = [], signals } = range;
|
|
9
|
+
const ids = diaIDs.slice();
|
|
10
|
+
for (const signal of signals) {
|
|
11
|
+
if (signal?.diaIDs) {
|
|
12
|
+
ids.push(...signal.diaIDs);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return ids;
|
|
16
|
+
}
|
|
17
|
+
function useAtoms(range) {
|
|
18
|
+
const topicMolecule = useTopicMolecule();
|
|
19
|
+
const diaIDs = getDiaIds(range);
|
|
20
|
+
const atomsList = [];
|
|
21
|
+
for (const [id, topicMoleculeObject] of Object.entries(topicMolecule)) {
|
|
22
|
+
const atoms = [];
|
|
23
|
+
const diaIDsObject = topicMoleculeObject.getDiaIDsObject();
|
|
24
|
+
for (const id of diaIDs) {
|
|
25
|
+
const existingAtoms = diaIDsObject[id]?.existingAtoms;
|
|
26
|
+
if (existingAtoms?.length > 0) {
|
|
27
|
+
atoms.push(...existingAtoms);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (atoms.length > 0) {
|
|
31
|
+
atomsList.push({ id, atoms: [...new Set(atoms.sort((a, b) => a - b))] });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return atomsList;
|
|
35
|
+
}
|
|
36
|
+
export function Atoms(props) {
|
|
37
|
+
const { range, x } = props;
|
|
38
|
+
const { view: { molecules }, } = useChartData();
|
|
39
|
+
const atomsList = useAtoms(range).filter((atomsList) => molecules?.[atomsList.id]?.showAtomNumber);
|
|
40
|
+
return (_jsx("g", { transform: `translate(${x},${marginTop})`, children: atomsList.map((row, rowIndex) => (
|
|
41
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
42
|
+
_jsx("g", { transform: `translate(${rowIndex * lineHeight}, 0)`, children: row.atoms.map((item, colIndex) => (_jsx("text", { x: 0, y: colIndex * lineHeight, fontSize: fontSize, fill: "black", children: item }, colIndex))) }, rowIndex))) }));
|
|
43
|
+
}
|
|
@@ -15,6 +15,7 @@ import { IntegralIndicator } from '../integral/IntegralIndicator';
|
|
|
15
15
|
import { MultiplicityTree } from '../multiplicityTree/MultiplicityTree';
|
|
16
16
|
import { useScaleX } from '../utilities/scale';
|
|
17
17
|
import { AssignmentActionsButtons } from './AssignmentActionsButtons';
|
|
18
|
+
import { Atoms } from './Atoms';
|
|
18
19
|
const style = css `
|
|
19
20
|
.target {
|
|
20
21
|
visibility: hidden;
|
|
@@ -27,7 +28,7 @@ const style = css `
|
|
|
27
28
|
}
|
|
28
29
|
`;
|
|
29
30
|
function Range({ range, showMultiplicityTrees, selectedTool, relativeFormat, }) {
|
|
30
|
-
const { id, integration, signals, diaIDs, from, to } = range;
|
|
31
|
+
const { id, integration, signals, diaIDs: rangeDiaIDs, from, to } = range;
|
|
31
32
|
const assignmentData = useAssignmentData();
|
|
32
33
|
const assignmentRange = useAssignment(id);
|
|
33
34
|
const highlightRange = useHighlight([assignmentRange.id].concat(assignmentRange.assigned?.x || []).concat(filterForIDsWithAssignment(assignmentData, signals.map((_signal) => _signal.id))), { type: HighlightEventSource.RANGE, extra: { id } });
|
|
@@ -74,9 +75,10 @@ function Range({ range, showMultiplicityTrees, selectedTool, relativeFormat, })
|
|
|
74
75
|
const isHighlighted = isBlockedByEditing || highlightRange.isActive || assignmentRange.isActive;
|
|
75
76
|
const isAssigned = isRangeAssigned(range);
|
|
76
77
|
const isResizingActive = useResizerStatus('rangePicking');
|
|
78
|
+
const startX = scaleX()(from) - 16;
|
|
77
79
|
return (_jsxs("g", { "data-testid": "range", style: { outline: 'none' }, onMouseEnter: mouseEnterHandler, onMouseLeave: mouseLeaveHandler, ...(!assignmentRange.isActive && { css: style }), children: [_jsx(ResizerWithScale, { from: from, to: to, onEnd: handleOnStopResizing, disabled: !isResizingActive, children: ({ x1, x2 }, isActive) => {
|
|
78
80
|
const width = x2 - x1;
|
|
79
81
|
return (_jsxs("g", { children: [isAssigned && !isHighlighted && !isActive && (_jsx("rect", { width: width, height: "10px", fill: "#ffd700", opacity: "0.35", "data-no-export": "true" })), _jsx("rect", { width: width, height: "100%", fill: isHighlighted || isActive ? '#ff6f0057' : 'transparent', "data-no-export": "true" }), showIntegralsValues && (_jsx(IntegralIndicator, { value: integration, format: relativeFormat, width: width, opacity: isNotSignal ? 0.5 : 1 }))] }));
|
|
80
|
-
} }), showMultiplicityTrees && (_jsx(MultiplicityTree, { range: range, onUnlink: unAssignHandler })), _jsx(AssignmentActionsButtons, { isActive: !!(assignmentRange.isActive ||
|
|
82
|
+
} }), showMultiplicityTrees && (_jsx(MultiplicityTree, { range: range, onUnlink: unAssignHandler })), _jsx(Atoms, { range: range, x: startX }), _jsx(AssignmentActionsButtons, { isActive: !!(assignmentRange.isActive || rangeDiaIDs), x: startX, onAssign: assignHandler, onUnAssign: () => unAssignHandler() })] }, id));
|
|
81
83
|
}
|
|
82
84
|
export default Range;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useChartData } from '../../context/ChartContext';
|
|
3
|
+
import { useScaleChecked } from '../../context/ScaleContext';
|
|
4
|
+
import { options } from '../../toolbar/ToolTypes';
|
|
5
|
+
const styles = {
|
|
6
|
+
transformOrigin: 'top left',
|
|
7
|
+
position: 'absolute',
|
|
8
|
+
top: '0px',
|
|
9
|
+
left: '0px',
|
|
10
|
+
height: 1,
|
|
11
|
+
backgroundColor: 'yellow',
|
|
12
|
+
};
|
|
13
|
+
function BaseLine() {
|
|
14
|
+
const { width, margin: { left, right }, toolOptions: { selectedTool }, } = useChartData();
|
|
15
|
+
const { scaleY } = useScaleChecked();
|
|
16
|
+
const innerWidth = width - left - right;
|
|
17
|
+
if (![options.phaseCorrection.id, options.baselineCorrection.id].includes(selectedTool)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return (_jsx("div", { style: {
|
|
21
|
+
...styles,
|
|
22
|
+
transform: `translate(${left}px, ${scaleY()(0)}px)`,
|
|
23
|
+
width: innerWidth,
|
|
24
|
+
} }));
|
|
25
|
+
}
|
|
26
|
+
export default BaseLine;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useChartData } from '../../context/ChartContext';
|
|
3
|
+
import { useDispatch } from '../../context/DispatchContext';
|
|
3
4
|
import { useScaleChecked } from '../../context/ScaleContext';
|
|
5
|
+
import { ResizerWithScale } from '../../elements/ResizerWithScale';
|
|
4
6
|
import { useHighlight } from '../../highlight';
|
|
7
|
+
import { useResizerStatus } from '../../hooks/useResizerStatus';
|
|
5
8
|
function BaseLineZones() {
|
|
6
9
|
const { toolOptions: { selectedTool, data: { baselineCorrection }, }, } = useChartData();
|
|
7
10
|
const baseLineZones = baselineCorrection.zones;
|
|
@@ -14,8 +17,20 @@ function BaseLineZone(props) {
|
|
|
14
17
|
const { from, to, id } = props;
|
|
15
18
|
const { onHover, isActive, defaultActiveStyle: { backgroundColor: activeFill }, } = useHighlight([id], { type: 'BASELINE_ZONE', extra: { id } });
|
|
16
19
|
const { scaleX } = useScaleChecked();
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
const dispatch = useDispatch();
|
|
21
|
+
function handleOnStopResizing(position) {
|
|
22
|
+
dispatch({
|
|
23
|
+
type: 'RESIZE_BASE_LINE_ZONE',
|
|
24
|
+
payload: {
|
|
25
|
+
id,
|
|
26
|
+
from: scaleX().invert(position.x2),
|
|
27
|
+
to: scaleX().invert(position.x1),
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const isResizingActive = useResizerStatus('baselineCorrection');
|
|
32
|
+
return (_jsx("g", { ...onHover, className: "base-line-zones", children: _jsx(ResizerWithScale, { from: from, to: to, onEnd: handleOnStopResizing, disabled: !isResizingActive, children: ({ x1, x2 }, isResizeActive) => {
|
|
33
|
+
return (_jsx("rect", { width: Math.abs(x2 - x1), height: "100%", fill: isActive && !isResizeActive ? activeFill : '#b8b8b857' }));
|
|
34
|
+
} }) }));
|
|
20
35
|
}
|
|
21
36
|
export default BaseLineZones;
|
|
@@ -14,6 +14,7 @@ interface ScaleYOptions {
|
|
|
14
14
|
yDomain: number[];
|
|
15
15
|
verticalAlign: VerticalAlignment;
|
|
16
16
|
}
|
|
17
|
+
export declare const SPECTRA_BOTTOM_MARGIN = 40;
|
|
17
18
|
declare function getYScale(options: ScaleYOptions, spectrumId?: number | null | string): import("d3-scale").ScaleLinear<number, number, never>;
|
|
18
19
|
interface IntegralYScaleOptions {
|
|
19
20
|
height: number;
|
|
@@ -9,6 +9,7 @@ function getXScale(options, spectrumId = null) {
|
|
|
9
9
|
: [margin.left, width - margin.right];
|
|
10
10
|
return scaleLinear(spectrumId ? xDomains[spectrumId] : xDomain, range);
|
|
11
11
|
}
|
|
12
|
+
export const SPECTRA_BOTTOM_MARGIN = 40;
|
|
12
13
|
function getYScale(options, spectrumId = null) {
|
|
13
14
|
const { height, margin, verticalAlign, yDomain, yDomains } = options;
|
|
14
15
|
let domainY = yDomain;
|
|
@@ -16,7 +17,7 @@ function getYScale(options, spectrumId = null) {
|
|
|
16
17
|
domainY = yDomains[spectrumId];
|
|
17
18
|
}
|
|
18
19
|
const [min, max] = domainY;
|
|
19
|
-
let bottomShift =
|
|
20
|
+
let bottomShift = SPECTRA_BOTTOM_MARGIN;
|
|
20
21
|
if (verticalAlign === 'center') {
|
|
21
22
|
bottomShift = 0;
|
|
22
23
|
const maxim = Math.max(Math.abs(max), Math.abs(min));
|
|
@@ -9,12 +9,14 @@ import { FidContainer } from './fid/FidContainer';
|
|
|
9
9
|
import { FTContainer } from './ft/FTContainer';
|
|
10
10
|
import IndicationLines from './zones/IndicationLines';
|
|
11
11
|
import Zones from './zones/Zones';
|
|
12
|
-
function chart2DInner({ spectra, width, height, margin, displayerKey,
|
|
13
|
-
return (_jsxs("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height,
|
|
12
|
+
function chart2DInner({ spectra, width, height, margin, displayerKey, spectraRendering, }) {
|
|
13
|
+
return (_jsxs("svg", { id: "nmrSVG", viewBox: `0 0 ${width} ${height}`, width: width, height: height, fontFamily: "Arial, Helvetica, sans-serif", shapeRendering: spectraRendering, style: {
|
|
14
|
+
position: 'absolute',
|
|
15
|
+
}, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-chart-2d`, children: _jsx("rect", { width: width - margin.left - margin.right, height: height - margin.top - margin.bottom, x: margin.left, y: margin.top }) }) }), _jsx("rect", { width: width - margin.left - margin.right, height: height - margin.top - margin.bottom, x: margin.left, y: margin.top, stroke: "black", strokeWidth: "1", fill: "transparent" }), _jsx(FTContainer, { spectra: spectra }), _jsx(FidContainer, {}), _jsx(Zones, {}), _jsx(IndicationLines, { axis: "X", show: true }), _jsx(IndicationLines, { axis: "Y", show: true }), _jsx(SpectrumInfoBlock, {}), _jsxs("g", { className: "container", style: { pointerEvents: 'none' }, children: [_jsx(XAxis, {}), _jsx(YAxis, {})] })] }));
|
|
14
16
|
}
|
|
15
17
|
const MemoizedChart2D = memo(chart2DInner);
|
|
16
18
|
export default function Chart2D({ spectra }) {
|
|
17
19
|
const { width, height, margin, displayerKey } = useChartData();
|
|
18
|
-
const { current: { general: {
|
|
19
|
-
return (_jsx(MemoizedChart2D, { spectra, width, height, margin, displayerKey,
|
|
20
|
+
const { current: { general: { spectraRendering }, }, } = usePreferences();
|
|
21
|
+
return (_jsx(MemoizedChart2D, { spectra, width, height, margin, displayerKey, spectraRendering }));
|
|
20
22
|
}
|