nmrium 0.48.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/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/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/2d/Chart2D.js +6 -4
- package/lib/component/2d/Viewer2D.js +35 -26
- package/lib/component/context/KeyModifierContext.d.ts +13 -2
- 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/useToolsFunctions.js +4 -2
- package/lib/component/main/InnerNMRium.js +2 -1
- 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/setting/settings-tabs/GeneralTabContent.js +9 -11
- 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 +3 -3
- package/lib/component/panels/SpectrumsPanel/SpectrumListPanel.js +4 -2
- package/lib/component/panels/SpectrumsPanel/base/SpectraColumnsManager.js +19 -16
- package/lib/component/reducer/Reducer.js +2 -0
- package/lib/component/reducer/actions/FiltersActions.d.ts +3 -4
- package/lib/component/reducer/actions/FiltersActions.js +92 -55
- 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 +3 -3
- package/lib/component/reducer/actions/ToolsActions.d.ts +8 -5
- package/lib/component/reducer/actions/ToolsActions.js +51 -44
- package/lib/component/toolbar/BasicToolBar.js +11 -29
- package/lib/component/utility/export.js +3 -0
- 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/versionInfo.js +1 -1
- package/package.json +18 -17
- 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;
|
|
@@ -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
|
}
|
|
@@ -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;
|
|
@@ -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
|
}
|
|
@@ -8,6 +8,7 @@ import { BrushTracker, } from '../EventsTrackers/BrushTracker';
|
|
|
8
8
|
import { MouseTracker } from '../EventsTrackers/MouseTracker';
|
|
9
9
|
import { useChartData } from '../context/ChartContext';
|
|
10
10
|
import { useDispatch } from '../context/DispatchContext';
|
|
11
|
+
import { useMapKeyModifiers } from '../context/KeyModifierContext';
|
|
11
12
|
import Spinner from '../loader/Spinner';
|
|
12
13
|
import { options } from '../toolbar/ToolTypes';
|
|
13
14
|
import { PhaseTraces } from './1d-tracer/phase-correction-traces';
|
|
@@ -23,6 +24,7 @@ function Viewer2D({ emptyText = undefined }) {
|
|
|
23
24
|
const { toolOptions: { selectedTool }, isLoading, data, margin, view: { spectra: { activeSpectra, activeTab }, }, } = state;
|
|
24
25
|
const dispatch = useDispatch();
|
|
25
26
|
const brushStartRef = useRef(null);
|
|
27
|
+
const { getModifiersKey, primaryKeyIdentifier } = useMapKeyModifiers();
|
|
26
28
|
const spectrumData = useMemo(() => {
|
|
27
29
|
const nuclei = activeTab.split(',');
|
|
28
30
|
return nuclei
|
|
@@ -58,41 +60,48 @@ function Viewer2D({ emptyText = undefined }) {
|
|
|
58
60
|
const handelBrushEnd = useCallback((brushData) => {
|
|
59
61
|
//reset the brush start
|
|
60
62
|
brushStartRef.current = null;
|
|
63
|
+
const modifierKey = getModifiersKey(brushData);
|
|
64
|
+
let executeDefaultAction = false;
|
|
61
65
|
if (brushData.mouseButton === 'main') {
|
|
62
66
|
const trackID = getLayoutID(DIMENSION, brushData);
|
|
63
67
|
if (trackID) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
switch (modifierKey) {
|
|
69
|
+
case primaryKeyIdentifier: {
|
|
70
|
+
switch (selectedTool) {
|
|
71
|
+
case options.zoom.id: {
|
|
72
|
+
executeDefaultAction = true;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case options.zonePicking.id: {
|
|
76
|
+
dispatch({ type: 'ADD_2D_ZONE', payload: brushData });
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
default:
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
68
83
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
case options.zonePicking.id:
|
|
73
|
-
dispatch({ type: 'ADD_2D_ZONE', payload: brushData });
|
|
74
|
-
break;
|
|
75
|
-
default:
|
|
76
|
-
break;
|
|
84
|
+
default: {
|
|
85
|
+
executeDefaultAction = true;
|
|
86
|
+
break;
|
|
77
87
|
}
|
|
78
88
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
89
|
+
const isNotDistanceMeasurementTool = selectedTool !== 'zoom' ||
|
|
90
|
+
(selectedTool === 'zoom' && !brushData.shiftKey);
|
|
91
|
+
if (executeDefaultAction &&
|
|
92
|
+
selectedTool != null &&
|
|
93
|
+
isNotDistanceMeasurementTool) {
|
|
94
|
+
return dispatch({
|
|
95
|
+
type: 'BRUSH_END',
|
|
96
|
+
payload: {
|
|
97
|
+
...brushData,
|
|
98
|
+
trackID: getLayoutID(DIMENSION, brushData),
|
|
99
|
+
},
|
|
100
|
+
});
|
|
92
101
|
}
|
|
93
102
|
}
|
|
94
103
|
}
|
|
95
|
-
}, [selectedTool,
|
|
104
|
+
}, [getModifiersKey, DIMENSION, selectedTool, primaryKeyIdentifier, dispatch]);
|
|
96
105
|
const handelOnDoubleClick = useCallback((e) => {
|
|
97
106
|
const { x: startX, y: startY } = e;
|
|
98
107
|
const trackID = getLayoutID(DIMENSION, { startX, startY });
|