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.
Files changed (88) hide show
  1. package/lib/component/1d/Chart1D.js +1 -1
  2. package/lib/component/1d/Line.js +1 -1
  3. package/lib/component/1d/LinesSeries.d.ts +1 -1
  4. package/lib/component/1d/LinesSeries.js +24 -3
  5. package/lib/component/1d/SpectraLegends.js +1 -1
  6. package/lib/component/1d/Viewer1D.js +144 -124
  7. package/lib/component/1d/jCouplingGraph/JsCoupling.js +1 -1
  8. package/lib/component/1d/peaks/Peaks.js +5 -4
  9. package/lib/component/1d/ranges/Atoms.d.ts +7 -0
  10. package/lib/component/1d/ranges/Atoms.js +43 -0
  11. package/lib/component/1d/ranges/Range.js +4 -2
  12. package/lib/component/1d/tool/BaseLine.d.ts +2 -0
  13. package/lib/component/1d/tool/BaseLine.js +26 -0
  14. package/lib/component/1d/tool/BaseLineZones.js +18 -3
  15. package/lib/component/1d/utilities/scale.d.ts +1 -0
  16. package/lib/component/1d/utilities/scale.js +2 -1
  17. package/lib/component/2d/Chart2D.js +6 -4
  18. package/lib/component/2d/Viewer2D.js +35 -26
  19. package/lib/component/context/KeyModifierContext.d.ts +14 -3
  20. package/lib/component/context/KeyModifierContext.js +35 -4
  21. package/lib/component/context/LoggerContext.d.ts +9 -0
  22. package/lib/component/context/LoggerContext.js +21 -7
  23. package/lib/component/context/PreferencesContext.d.ts +1 -108
  24. package/lib/component/context/TopicMoleculeContext.d.ts +8 -0
  25. package/lib/component/context/TopicMoleculeContext.js +30 -0
  26. package/lib/component/elements/Input.js +4 -1
  27. package/lib/component/elements/ResizerWithScale.js +19 -2
  28. package/lib/component/elements/SVGGroup.js +2 -2
  29. package/lib/component/elements/formik/FormikTextarea.js +8 -9
  30. package/lib/component/elements/linearAxis/LinearVerticalAxis.js +1 -1
  31. package/lib/component/elements/resizer/SVGResizer.js +1 -1
  32. package/lib/component/header/BaseLineCorrectionPanel.js +3 -2
  33. package/lib/component/header/Header.js +2 -2
  34. package/lib/component/hooks/useCheckToolsVisibility.js +1 -1
  35. package/lib/component/hooks/useExport.js +2 -2
  36. package/lib/component/hooks/useSetActiveSpectrumAction.d.ts +3 -0
  37. package/lib/component/hooks/useSetActiveSpectrumAction.js +16 -0
  38. package/lib/component/hooks/useToolsFunctions.js +4 -2
  39. package/lib/component/hooks/useVerticalAlign.d.ts +1 -1
  40. package/lib/component/main/InnerNMRium.js +3 -2
  41. package/lib/component/modal/ExportAsJcampModal.js +1 -1
  42. package/lib/component/modal/ImportPublicationStringModal.d.ts +2 -1
  43. package/lib/component/modal/ImportPublicationStringModal.js +76 -32
  44. package/lib/component/modal/editRange/forms/validation/EditRangeValidation.js +2 -4
  45. package/lib/component/modal/setting/settings-tabs/GeneralTabContent.js +9 -11
  46. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +2 -1
  47. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts +2 -1
  48. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -5
  49. package/lib/component/panels/RangesPanel/RangesTable.js +1 -1
  50. package/lib/component/panels/SpectrumsPanel/SpectraPreferences.js +39 -5
  51. package/lib/component/panels/SpectrumsPanel/SpectraTable.js +28 -40
  52. package/lib/component/panels/SpectrumsPanel/SpectrumListPanel.js +4 -2
  53. package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.js +3 -9
  54. package/lib/component/panels/SpectrumsPanel/base/RenderAsHTML.d.ts +7 -0
  55. package/lib/component/panels/SpectrumsPanel/base/RenderAsHTML.js +21 -0
  56. package/lib/component/panels/SpectrumsPanel/base/SpectraColumnsManager.js +19 -16
  57. package/lib/component/panels/SpectrumsPanel/base/SpectrumName.js +0 -1
  58. package/lib/component/panels/databasePanel/DatabasePanel.js +6 -1
  59. package/lib/component/panels/multipleAnalysisPanel/AnalysisChart.js +1 -1
  60. package/lib/component/panels/predictionPanel/PredictionPanel.js +3 -1
  61. package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +15 -4
  62. package/lib/component/reducer/Reducer.js +2 -0
  63. package/lib/component/reducer/actions/DomainActions.d.ts +2 -2
  64. package/lib/component/reducer/actions/DomainActions.js +2 -2
  65. package/lib/component/reducer/actions/FiltersActions.d.ts +3 -4
  66. package/lib/component/reducer/actions/FiltersActions.js +93 -57
  67. package/lib/component/reducer/actions/LoadActions.js +10 -8
  68. package/lib/component/reducer/actions/SpectrumsActions.d.ts +8 -1
  69. package/lib/component/reducer/actions/SpectrumsActions.js +8 -4
  70. package/lib/component/reducer/actions/ToolsActions.d.ts +8 -5
  71. package/lib/component/reducer/actions/ToolsActions.js +51 -44
  72. package/lib/component/reducer/helper/getVerticalAlign.d.ts +1 -1
  73. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +0 -4
  74. package/lib/component/toolbar/BasicToolBar.js +11 -29
  75. package/lib/component/utility/export.d.ts +3 -2
  76. package/lib/component/utility/export.js +45 -26
  77. package/lib/component/workspaces/exercise.js +1 -0
  78. package/lib/component/workspaces/prediction.js +1 -16
  79. package/lib/component/workspaces/simulation.js +1 -2
  80. package/lib/component/workspaces/workspaceDefaultProperties.js +4 -3
  81. package/lib/data/data1d/Spectrum1D/index.d.ts +0 -1
  82. package/lib/data/data1d/Spectrum1D/index.js +0 -1
  83. package/lib/data/data1d/multipleSpectraAnalysis.js +27 -40
  84. package/lib/data/data2d/Spectrum2D/getMissingProjection.js +10 -1
  85. package/lib/versionInfo.js +1 -1
  86. package/package.json +31 -30
  87. package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.d.ts +0 -2
  88. 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}`, width: width, height: height, id: "nmrSVG", 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(Ranges, {}), _jsx(Peaks, { peaksSource: "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 }) })] }) }));
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;
@@ -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})` }, id));
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
- return (_jsxs("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, className: "spectrums", children: [spectra.map((d, i) => (_jsx("g", { id: d.id, children: _jsx(Line, { display: d.display, id: d.id, data: get1DDataXY(d), index: i }) }, d.id))), activeSpectra?.map((activeSpectrum) => (_jsx("use", { href: `#${activeSpectrum.id}` }, activeSpectrum.id)))] }));
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, style: { transform: 'translate(12px,0)' }, children: legendsFields.map((field) => {
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
- if (brushData.altKey) {
96
- switch (selectedTool) {
97
- case options.rangePicking.id: {
98
- openAnalysisModal();
99
- break;
100
- }
101
- default:
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
- dispatch({
117
- type: 'ADD_RANGE',
118
- payload: brushData,
119
- });
120
- break;
121
- }
122
- case options.multipleSpectraAnalysis.id:
123
- if (scaleState.scaleX) {
124
- const { startX, endX } = brushData;
125
- const start = scaleState.scaleX().invert(startX);
126
- const end = scaleState.scaleX().invert(endX);
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: 'ANALYZE_SPECTRA',
165
+ type: 'ADD_MATRIX_GENERATION_EXCLUSION_ZONE',
129
166
  payload: {
130
- start,
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
- break;
137
- case options.peakPicking.id:
138
- dispatch({
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
- default:
174
- propagateEvent();
175
- break;
178
+ break;
176
179
  }
177
- }
178
- else {
179
- switch (selectedTool) {
180
- default:
181
- if (selectedTool != null) {
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
- break;
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
- scaleState,
206
+ getModifiersKey,
190
207
  selectedTool,
191
- openAnalysisModal,
192
- activeSpectrum,
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
- if (event.shiftKey) {
219
- switch (selectedTool) {
220
- case options.peakPicking.id:
221
- dispatch({
222
- type: 'ADD_PEAK',
223
- payload: event,
224
- });
225
- break;
226
- case options.editRange.id:
227
- propagateEvent();
228
- break;
229
- case options.integral.id:
230
- dispatch({
231
- type: 'CUT_INTEGRAL',
232
- payload: { cutValue: xPPM },
233
- });
234
- break;
235
- case options.rangePicking.id:
236
- dispatch({
237
- type: 'CUT_RANGE',
238
- payload: { cutValue: xPPM },
239
- });
240
- break;
241
- case options.phaseCorrection.id:
242
- dispatch({
243
- type: 'SET_ONE_DIMENSION_PIVOT_POINT',
244
- payload: {
245
- value: event.x,
246
- },
247
- });
248
- break;
249
- default:
250
- break;
251
- }
252
- }
253
- else {
254
- switch (selectedTool) {
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", style: { transform: `translate(0px,${scaleY(value)}px)` }, 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", { style: { transform: `translate(0px,15px)` }, 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` })] }))] }));
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 (!spectrum.peaks?.values ||
73
- !peaksViewState.showPeaks ||
74
- canDisplaySpectrumPeaks) {
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
- (!spectrum.ranges?.values ||
79
+ (spectrum.ranges?.values?.length === 0 ||
79
80
  !rangesViewState.showPeaks ||
80
81
  canDisplaySpectrumPeaks)) {
81
82
  return null;
@@ -0,0 +1,7 @@
1
+ import { Range } from 'nmr-processing';
2
+ interface AtomsProps {
3
+ range: Range;
4
+ x: number;
5
+ }
6
+ export declare function Atoms(props: AtomsProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -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 || diaIDs), x: scaleX()(from) - 16, onAssign: assignHandler, onUnAssign: () => unAssignHandler() })] }, id));
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,2 @@
1
+ declare function BaseLine(): import("react/jsx-runtime").JSX.Element | null;
2
+ export default BaseLine;
@@ -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 x = scaleX()(to);
18
- const width = scaleX()(from) - scaleX()(to);
19
- return (_jsx("g", { transform: `translate(${x},0)`, ...onHover, children: _jsx("rect", { x: "0", width: width, height: "100%", style: { backgroundColor: 'red' }, fill: isActive ? activeFill : '#b8b8b857' }) }));
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 = 40;
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, SpectraRendering, }) {
13
- return (_jsxs("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, id: "nmrSVG", shapeRendering: SpectraRendering, style: { position: 'absolute' }, 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, {})] })] }));
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: { SpectraRendering }, }, } = usePreferences();
19
- return (_jsx(MemoizedChart2D, { spectra, width, height, margin, displayerKey, SpectraRendering }));
20
+ const { current: { general: { spectraRendering }, }, } = usePreferences();
21
+ return (_jsx(MemoizedChart2D, { spectra, width, height, margin, displayerKey, spectraRendering }));
20
22
  }