nmrium 0.50.1 → 0.51.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 (151) hide show
  1. package/lib/component/1d/Chart1D.js +1 -1
  2. package/lib/component/1d/LinesSeries.js +2 -2
  3. package/lib/component/1d/Viewer1D.js +6 -11
  4. package/lib/component/1d/database/DatabaseSpectrum.js +3 -3
  5. package/lib/component/2d/1d-tracer/HorizontalSliceChart.js +6 -2
  6. package/lib/component/2d/1d-tracer/VerticalSliceChart.js +8 -1
  7. package/lib/component/2d/1d-tracer/phase-correction-traces/PhaseTraceWithMouse.js +2 -21
  8. package/lib/component/2d/1d-tracer/phase-correction-traces/PhaseTraces.js +1 -1
  9. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectraPhaseTraces.d.ts +1 -1
  10. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectraPhaseTraces.js +6 -17
  11. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.d.ts +6 -10
  12. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.js +62 -13
  13. package/lib/component/2d/1d-tracer/phase-correction-traces/useActivePhaseTraces.d.ts +1 -0
  14. package/lib/component/2d/1d-tracer/phase-correction-traces/useActivePhaseTraces.js +2 -1
  15. package/lib/component/2d/Viewer2D.js +16 -15
  16. package/lib/component/2d/ft/Contours.js +6 -3
  17. package/lib/component/2d/utilities/scale.d.ts +2 -1
  18. package/lib/component/2d/utilities/scale.js +12 -2
  19. package/lib/component/EventsTrackers/BrushTracker.d.ts +5 -3
  20. package/lib/component/EventsTrackers/BrushTracker.js +2 -2
  21. package/lib/component/EventsTrackers/KeysListenerTracker.d.ts +1 -1
  22. package/lib/component/EventsTrackers/KeysListenerTracker.js +29 -15
  23. package/lib/component/context/ToasterContext.d.ts +13 -0
  24. package/lib/component/context/ToasterContext.js +34 -0
  25. package/lib/component/elements/Select.js +2 -2
  26. package/lib/component/elements/ToolbarPopoverItem.js +1 -1
  27. package/lib/component/header/AutoPeakPickingOptionPanel.js +6 -3
  28. package/lib/component/header/Header.d.ts +1 -11
  29. package/lib/component/header/Header.js +5 -6
  30. package/lib/component/header/PhaseCorrectionPanel.js +24 -33
  31. package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.d.ts +1 -1
  32. package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.js +96 -42
  33. package/lib/component/header/RangesPickingOptionPanel.js +6 -3
  34. package/lib/component/hooks/useDialogToggle.d.ts +5 -0
  35. package/lib/component/hooks/useDialogToggle.js +16 -0
  36. package/lib/component/hooks/useExport.d.ts +9 -1
  37. package/lib/component/hooks/useExport.js +34 -36
  38. package/lib/component/hooks/useSaveSettings.js +6 -3
  39. package/lib/component/hooks/useToolsFunctions.js +6 -4
  40. package/lib/component/loader/DropZone.js +14 -14
  41. package/lib/component/main/InnerNMRium.js +5 -9
  42. package/lib/component/main/InnerNMRiumContents.d.ts +0 -2
  43. package/lib/component/main/InnerNMRiumContents.js +5 -3
  44. package/lib/component/main/NMRium.js +2 -2
  45. package/lib/component/modal/AboutPredictionModal.js +1 -1
  46. package/lib/component/modal/ExportAsJcampModal.js +15 -15
  47. package/lib/component/modal/ImportPublicationStringModal.js +5 -3
  48. package/lib/component/modal/LoadJCAMPModal.js +6 -4
  49. package/lib/component/modal/PredictSpectraModal.js +11 -9
  50. package/lib/component/modal/SaveAsModal.d.ts +3 -4
  51. package/lib/component/modal/SaveAsModal.js +27 -27
  52. package/lib/component/modal/editRange/EditRangeModal.js +2 -2
  53. package/lib/component/modal/editRange/forms/components/DeltaInput.d.ts +2 -3
  54. package/lib/component/modal/editRange/forms/components/DeltaInput.js +2 -3
  55. package/lib/component/modal/editRange/forms/components/InfoBlock.d.ts +1 -0
  56. package/lib/component/modal/editRange/forms/components/{SignalFormInfo.js → InfoBlock.js} +2 -2
  57. package/lib/component/modal/editRange/forms/components/NewSignalTab.d.ts +5 -0
  58. package/lib/component/modal/editRange/forms/components/NewSignalTab.js +85 -0
  59. package/lib/component/modal/editRange/forms/components/SignalTab.d.ts +7 -0
  60. package/lib/component/modal/editRange/forms/components/SignalTab.js +24 -0
  61. package/lib/component/modal/editRange/forms/components/SignalsContent.d.ts +8 -0
  62. package/lib/component/modal/editRange/forms/components/SignalsContent.js +57 -0
  63. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.d.ts +5 -0
  64. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +133 -0
  65. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.d.ts +5 -0
  66. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +141 -0
  67. package/lib/component/modal/metaImportation/MetaImportationModal.d.ts +7 -4
  68. package/lib/component/modal/metaImportation/MetaImportationModal.js +23 -13
  69. package/lib/component/modal/metaImportation/utils/mapColumnToSelectItems.js +1 -1
  70. package/lib/component/modal/setting/GeneralSettings.js +7 -4
  71. package/lib/component/panels/AutomaticAssignment/useAutoAssignments.js +7 -4
  72. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +13 -7
  73. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +6 -4
  74. package/lib/component/panels/PeaksPanel/PeaksPanel.js +6 -3
  75. package/lib/component/panels/RangesPanel/RangesHeader.js +3 -3
  76. package/lib/component/panels/RangesPanel/RangesPanel.js +4 -4
  77. package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -3
  78. package/lib/component/panels/SpectrumsPanel/SpectraTable.js +11 -5
  79. package/lib/component/panels/databasePanel/DatabasePanel.js +37 -19
  80. package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +1 -1
  81. package/lib/component/panels/filtersPanel/FilterPanel.js +5 -3
  82. package/lib/component/panels/filtersPanel/FiltersTable.js +27 -23
  83. package/lib/component/panels/header/SpectraAutomaticPickingButton.js +6 -4
  84. package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +2 -2
  85. package/lib/component/panels/multipleAnalysisPanel/AnalysisChart.js +3 -3
  86. package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +5 -5
  87. package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +4 -2
  88. package/lib/component/panels/predictionPanel/PredictionPanel.js +7 -5
  89. package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +1 -0
  90. package/lib/component/reducer/Reducer.d.ts +2 -2
  91. package/lib/component/reducer/Reducer.js +23 -16
  92. package/lib/component/reducer/actions/FiltersActions.d.ts +11 -4
  93. package/lib/component/reducer/actions/FiltersActions.js +243 -91
  94. package/lib/component/reducer/actions/IntegralsActions.js +2 -2
  95. package/lib/component/reducer/actions/MoleculeActions.js +0 -1
  96. package/lib/component/reducer/actions/RangesActions.js +16 -6
  97. package/lib/component/reducer/actions/ToolsActions.d.ts +3 -3
  98. package/lib/component/reducer/actions/ToolsActions.js +75 -14
  99. package/lib/component/reducer/helper/Zoom1DManager.d.ts +4 -3
  100. package/lib/component/reducer/helper/Zoom1DManager.js +4 -4
  101. package/lib/component/reducer/helper/ZoomHistoryManager.js +1 -5
  102. package/lib/component/reducer/helper/findStrongestPeak.d.ts +6 -0
  103. package/lib/component/reducer/helper/findStrongestPeak.js +13 -0
  104. package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.d.ts +2 -1
  105. package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.js +7 -1
  106. package/lib/component/toolbar/ToolBar.js +17 -12
  107. package/lib/component/utility/Events.d.ts +11 -0
  108. package/lib/component/utility/Events.js +22 -0
  109. package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +0 -33
  110. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +5 -15
  111. package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -4
  112. package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +1 -1
  113. package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +1 -1
  114. package/lib/data/data1d/Spectrum1D/ranges/detectRanges.d.ts +6 -4
  115. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +13 -3
  116. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +6 -0
  117. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.d.ts +13 -3
  118. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js +78 -18
  119. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +2 -2
  120. package/lib/data/data1d/spectrumSimulation.d.ts +1 -1
  121. package/lib/data/data2d/Spectrum2D/contours.js +3 -3
  122. package/lib/data/data2d/Spectrum2D/getMissingProjection.js +2 -2
  123. package/lib/data/data2d/Spectrum2D/getSlice.js +3 -3
  124. package/lib/data/getDefaultMatrixFilters.js +2 -2
  125. package/lib/data/matrixGeneration.js +1 -1
  126. package/lib/data/utilities/calculateSanPlot.d.ts +1 -6
  127. package/lib/versionInfo.js +1 -1
  128. package/package.json +31 -30
  129. package/lib/component/elements/popup/Alert/AlertBlock.d.ts +0 -8
  130. package/lib/component/elements/popup/Alert/AlertBlock.js +0 -30
  131. package/lib/component/elements/popup/Alert/Context.d.ts +0 -27
  132. package/lib/component/elements/popup/Alert/Context.js +0 -10
  133. package/lib/component/elements/popup/Alert/ProgressIndicator.d.ts +0 -1
  134. package/lib/component/elements/popup/Alert/ProgressIndicator.js +0 -33
  135. package/lib/component/elements/popup/Alert/Provider.d.ts +0 -19
  136. package/lib/component/elements/popup/Alert/Provider.js +0 -127
  137. package/lib/component/elements/popup/Alert/index.d.ts +0 -3
  138. package/lib/component/elements/popup/Alert/index.js +0 -3
  139. package/lib/component/modal/editRange/forms/components/AddSignalFormTab.d.ts +0 -10
  140. package/lib/component/modal/editRange/forms/components/AddSignalFormTab.js +0 -81
  141. package/lib/component/modal/editRange/forms/components/CouplingsTable.d.ts +0 -13
  142. package/lib/component/modal/editRange/forms/components/CouplingsTable.js +0 -63
  143. package/lib/component/modal/editRange/forms/components/SignalFormInfo.d.ts +0 -1
  144. package/lib/component/modal/editRange/forms/components/SignalFormTab.d.ts +0 -8
  145. package/lib/component/modal/editRange/forms/components/SignalFormTab.js +0 -18
  146. package/lib/component/modal/editRange/forms/components/SignalsForm.d.ts +0 -10
  147. package/lib/component/modal/editRange/forms/components/SignalsForm.js +0 -114
  148. package/lib/component/modal/metaImportation/index.d.ts +0 -2
  149. package/lib/component/modal/metaImportation/index.js +0 -17
  150. package/lib/component/reducer/helper/getStrongestPeak.d.ts +0 -7
  151. package/lib/component/reducer/helper/getStrongestPeak.js +0 -15
@@ -1,8 +1,9 @@
1
1
  import { v4 } from '@lukeed/uuid';
2
+ import { zoomIdentity } from 'd3';
2
3
  import { contoursManager } from '../../../data/data2d/Spectrum2D/contours';
3
4
  import { getYScale, getXScale } from '../../1d/utilities/scale';
4
5
  import { LAYOUT } from '../../2d/utilities/DimensionLayout';
5
- import { get2DYScale } from '../../2d/utilities/scale';
6
+ import { get2DXScale, get2DYScale } from '../../2d/utilities/scale';
6
7
  import { defaultRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
7
8
  import { options as Tools } from '../../toolbar/ToolTypes';
8
9
  import groupByInfoKey from '../../utility/GroupByInfoKey';
@@ -168,17 +169,70 @@ function handleBrushEnd(draft, action) {
168
169
  const domainY = startY > endY ? [endY, startY] : [startY, endY];
169
170
  addToBrushHistory(draft, { trackID, xDomain: domainX, yDomain: domainY });
170
171
  }
172
+ function zoomWithScroll(draft, options) {
173
+ const { zoomOptions, direction = 'Horizontal', dimension } = options;
174
+ let scaleX;
175
+ let scaleY;
176
+ if (dimension === '1D') {
177
+ scaleX = getXScale(draft);
178
+ }
179
+ else {
180
+ scaleX = get2DXScale(draft);
181
+ scaleY = get2DYScale(draft);
182
+ }
183
+ const scaleRatio = toScaleRatio(zoomOptions, { invert: true });
184
+ if (direction === 'Both' || direction === 'Horizontal') {
185
+ const { x } = zoomOptions;
186
+ const domain = zoomIdentity
187
+ .translate(x, 0)
188
+ .scale(scaleRatio)
189
+ .translate(-x, 0)
190
+ .rescaleX(scaleX)
191
+ .domain();
192
+ const { originDomain: { xDomain: [x1, x2], }, } = draft;
193
+ draft.xDomain = [
194
+ domain[0] < x1 ? x1 : domain[0],
195
+ domain[1] > x2 ? x2 : domain[1],
196
+ ];
197
+ }
198
+ if (dimension === '2D' &&
199
+ (direction === 'Both' || direction === 'Vertical')) {
200
+ const { y } = zoomOptions;
201
+ const domain = zoomIdentity
202
+ .translate(y, 0)
203
+ .scale(scaleRatio)
204
+ .translate(-y, 0)
205
+ .rescaleX(scaleY)
206
+ .domain();
207
+ const { originDomain: { yDomain: [x1, x2], }, } = draft;
208
+ draft.yDomain = [
209
+ domain[0] < x1 ? x1 : domain[0],
210
+ domain[1] > x2 ? x2 : domain[1],
211
+ ];
212
+ }
213
+ }
171
214
  function handleZoom(draft, action) {
172
- const { event, trackID } = action.payload;
215
+ const { options, trackID } = action.payload;
173
216
  const { displayerMode, yDomains, toolOptions: { selectedTool }, } = draft;
174
- const scaleRatio = toScaleRatio(event);
217
+ const scaleRatio = toScaleRatio(options);
175
218
  switch (displayerMode) {
176
219
  case '2D': {
177
- // change the vertical scale for traces in 2D phase correction
178
- if (selectedTool === 'phaseCorrectionTwoDimensions' &&
179
- trackID === 'CENTER_2D') {
180
- const { activeTraces } = getTwoDimensionPhaseCorrectionOptions(draft);
181
- activeTraces.scaleRatio *= scaleRatio;
220
+ const { shiftKey } = options;
221
+ if (trackID === 'CENTER_2D') {
222
+ // change the vertical scale for traces in 2D phase correction
223
+ if (selectedTool === 'phaseCorrectionTwoDimensions') {
224
+ const { activeTraces } = getTwoDimensionPhaseCorrectionOptions(draft);
225
+ activeTraces.scaleRatio *= scaleRatio;
226
+ return;
227
+ }
228
+ //zoom in/out in 2d
229
+ if (selectedTool === 'zoom' && shiftKey) {
230
+ zoomWithScroll(draft, {
231
+ zoomOptions: options,
232
+ dimension: '2D',
233
+ direction: 'Both',
234
+ });
235
+ }
182
236
  }
183
237
  else {
184
238
  // change the vertical scale of 1D traces
@@ -187,7 +241,7 @@ function handleZoom(draft, action) {
187
241
  const id = getSpectrumID(draft, index);
188
242
  if (id) {
189
243
  const domain = yDomains[id];
190
- yDomains[id] = wheelZoom(event, domain);
244
+ yDomains[id] = wheelZoom(options, domain);
191
245
  }
192
246
  }
193
247
  }
@@ -195,15 +249,21 @@ function handleZoom(draft, action) {
195
249
  }
196
250
  case '1D': {
197
251
  const activeSpectra = getActiveSpectra(draft);
252
+ const { shiftKey } = options;
253
+ // Horizontal zoom in/out 1d spectra by mouse wheel
254
+ if (selectedTool === 'zoom' && shiftKey) {
255
+ zoomWithScroll(draft, { zoomOptions: options, dimension: '1D' });
256
+ return;
257
+ }
198
258
  if (!activeSpectra) {
199
259
  // rescale the spectra
200
260
  for (const key of Object.keys(yDomains)) {
201
261
  const domain = yDomains[key];
202
- yDomains[key] = wheelZoom(event, domain);
262
+ yDomains[key] = wheelZoom(options, domain);
203
263
  }
204
264
  return;
205
265
  }
206
- if (activeSpectra.length === 1 && event.shiftKey) {
266
+ if (activeSpectra.length === 1 && shiftKey) {
207
267
  switch (selectedTool) {
208
268
  case 'rangePicking': {
209
269
  setRangesViewProperty(draft, 'integralsScaleRatio', (scale) => scale * scaleRatio);
@@ -221,7 +281,7 @@ function handleZoom(draft, action) {
221
281
  for (const activeSpectrum of activeSpectra) {
222
282
  const domain = yDomains?.[activeSpectrum?.id];
223
283
  if (domain) {
224
- yDomains[activeSpectrum?.id] = wheelZoom(event, domain);
284
+ yDomains[activeSpectrum?.id] = wheelZoom(options, domain);
225
285
  }
226
286
  }
227
287
  }
@@ -252,6 +312,7 @@ function zoomOut(draft, action) {
252
312
  draft.xDomain = zoomValue.xDomain;
253
313
  }
254
314
  else {
315
+ draft.xDomain = xDomain;
255
316
  setZoom(draft, { scale: 0.8 });
256
317
  }
257
318
  break;
@@ -411,7 +472,7 @@ function handelSetActiveTab(draft, action) {
411
472
  }
412
473
  }
413
474
  function levelChangeHandler(draft, action) {
414
- const { deltaY, shiftKey } = action.payload;
475
+ const { deltaY, altKey } = action.payload.options;
415
476
  const { data, view: { spectra: { activeTab }, zoom: { levels }, }, } = draft;
416
477
  const activeSpectra = getActiveSpectra(draft) || [];
417
478
  const activeSpectraObj = {};
@@ -424,7 +485,7 @@ function levelChangeHandler(draft, action) {
424
485
  for (const spectrum of spectra) {
425
486
  const contourOptions = spectrum.display.contourOptions;
426
487
  const zoom = contoursManager(spectrum.id, levels, contourOptions);
427
- levels[spectrum.id] = zoom.wheel(deltaY, shiftKey);
488
+ levels[spectrum.id] = zoom.wheel(deltaY, altKey);
428
489
  }
429
490
  }
430
491
  catch (error) {
@@ -1,4 +1,5 @@
1
1
  import { Draft } from 'immer';
2
+ import { ZoomOptions } from '../../EventsTrackers/BrushTracker';
2
3
  import { State } from '../Reducer';
3
4
  export declare const ZOOM_TYPES: {
4
5
  readonly HORIZONTAL: "HORIZONTAL";
@@ -7,12 +8,12 @@ export declare const ZOOM_TYPES: {
7
8
  readonly FULL: "FULL";
8
9
  };
9
10
  export type ZoomType = keyof typeof ZOOM_TYPES;
10
- declare function toScaleRatio(event: WheelEvent, zoomOptions?: ZoomOptions): number;
11
- interface ZoomOptions {
11
+ declare function toScaleRatio(options: ZoomOptions, zoomOptions?: ScaleRationOptions): number;
12
+ interface ScaleRationOptions {
12
13
  factor?: number;
13
14
  invert?: boolean;
14
15
  }
15
- declare function wheelZoom(event: WheelEvent, domain: number[], zoomOptions?: ZoomOptions): number[];
16
+ declare function wheelZoom(options: ZoomOptions, domain: number[], scaleOptions?: ScaleRationOptions): number[];
16
17
  declare function setZoom(draft: Draft<State>, options?: {
17
18
  scale?: number;
18
19
  spectrumID?: string;
@@ -6,15 +6,15 @@ export const ZOOM_TYPES = {
6
6
  STEP_HORIZONTAL: 'STEP_HORIZONTAL',
7
7
  FULL: 'FULL',
8
8
  };
9
- function toScaleRatio(event, zoomOptions = {}) {
9
+ function toScaleRatio(options, zoomOptions = {}) {
10
10
  const { factor = 1, invert = false } = zoomOptions;
11
- const deltaY = Math.abs(event.deltaY) < 100 ? event.deltaY * 100 : event.deltaY;
11
+ const deltaY = Math.abs(options.deltaY) < 100 ? options.deltaY * 100 : options.deltaY;
12
12
  const delta = deltaY * (invert ? -0.001 : 0.001) * factor;
13
13
  const ratio = delta < 0 ? -1 / (delta - 1) : 1 + delta;
14
14
  return ratio;
15
15
  }
16
- function wheelZoom(event, domain, zoomOptions = {}) {
17
- const ratio = toScaleRatio(event, zoomOptions);
16
+ function wheelZoom(options, domain, scaleOptions = {}) {
17
+ const ratio = toScaleRatio(options, scaleOptions);
18
18
  const [min, max] = domain;
19
19
  return [min * ratio, max * ratio];
20
20
  }
@@ -32,11 +32,7 @@ function prepareGetLast(historyStack) {
32
32
  export function addToBrushHistory(draft, options) {
33
33
  const { displayerMode } = draft;
34
34
  const { trackID, xDomain, yDomain } = options;
35
- const brushHistory = zoomHistoryManager(
36
- // eslint-disable-next-line unicorn/consistent-destructuring
37
- draft.zoom.history,
38
- // eslint-disable-next-line unicorn/consistent-destructuring
39
- draft.view.spectra.activeTab);
35
+ const brushHistory = zoomHistoryManager(draft.zoom.history, draft.view.spectra.activeTab);
40
36
  if (displayerMode === '2D') {
41
37
  switch (trackID) {
42
38
  case 'CENTER_2D':
@@ -0,0 +1,6 @@
1
+ import { NmrData1D } from 'cheminfo-types';
2
+ export declare function findStrongestPeak(data: NmrData1D): {
3
+ xValue: number;
4
+ yValue: number;
5
+ index: number;
6
+ } | null;
@@ -0,0 +1,13 @@
1
+ import { xFindClosestIndex } from 'ml-spectra-processing';
2
+ import { maxAbsoluteValue } from '../../utility/maxAbsoluteValue';
3
+ export function findStrongestPeak(data) {
4
+ if (!data)
5
+ return null;
6
+ const maxY = maxAbsoluteValue(data.re);
7
+ const index = xFindClosestIndex(data.re, maxY, { sorted: false });
8
+ return {
9
+ xValue: data.x[index],
10
+ yValue: maxY,
11
+ index,
12
+ };
13
+ }
@@ -1,5 +1,6 @@
1
1
  import type { Draft } from 'immer';
2
- import type { PhaseCorrectionTraceData, State, TwoDimensionPhaseCorrection } from '../Reducer';
2
+ import type { PhaseCorrectionTraceData, State, TraceDirection, TwoDimensionPhaseCorrection } from '../Reducer';
3
3
  export declare function getTwoDimensionPhaseCorrectionOptions(state: Draft<State> | State): Draft<TwoDimensionPhaseCorrection & {
4
4
  activeTraces: PhaseCorrectionTraceData;
5
5
  }>;
6
+ export declare function useTwoDimensionPhaseCorrectionOptions(direction: TraceDirection): PhaseCorrectionTraceData;
@@ -1,8 +1,14 @@
1
+ import { useChartData } from '../../context/ChartContext';
1
2
  export function getTwoDimensionPhaseCorrectionOptions(state) {
2
- const { toolOptions: { data: { twoDimensionPhaseCorrection: { traces, activeTraceDirection }, }, }, } = state;
3
+ const { toolOptions: { data: { twoDimensionPhaseCorrection: { traces, activeTraceDirection, addTracesToBothDirections, }, }, }, } = state;
3
4
  return {
4
5
  activeTraces: traces[activeTraceDirection],
5
6
  traces,
6
7
  activeTraceDirection,
8
+ addTracesToBothDirections,
7
9
  };
8
10
  }
11
+ export function useTwoDimensionPhaseCorrectionOptions(direction) {
12
+ const { toolOptions: { data: { twoDimensionPhaseCorrection: { traces }, }, }, } = useChartData();
13
+ return traces[direction];
14
+ }
@@ -3,7 +3,7 @@ import { SvgNmrAlignBottom, SvgNmrAlignCenter, SvgNmrApodization, SvgNmrBaseline
3
3
  import { useCallback } from 'react';
4
4
  import { FaSearchPlus, FaExpand, FaDiceFour, FaFileImport, FaFileExport, } from 'react-icons/fa';
5
5
  import { PiKnifeBold } from 'react-icons/pi';
6
- import { Toolbar, useOnOff } from 'react-science/ui';
6
+ import { Toolbar } from 'react-science/ui';
7
7
  import { useChartData } from '../context/ChartContext';
8
8
  import { useDispatch } from '../context/DispatchContext';
9
9
  import { useLoader } from '../context/LoaderContext';
@@ -11,12 +11,14 @@ import { ToolbarPopoverItem, } from '../elements/ToolbarPopoverItem';
11
11
  import useCheckExperimentalFeature from '../hooks/useCheckExperimentalFeature';
12
12
  import { useCheckToolsVisibility, } from '../hooks/useCheckToolsVisibility';
13
13
  import useDatumWithSpectraStatistics from '../hooks/useDatumWithSpectraStatistics';
14
+ import { useDialogToggle } from '../hooks/useDialogToggle';
14
15
  import useExport from '../hooks/useExport';
15
16
  import useToolsFunctions from '../hooks/useToolsFunctions';
16
17
  import { useVerticalAlign } from '../hooks/useVerticalAlign';
17
18
  import ImportPublicationStringModal from '../modal/ImportPublicationStringModal';
18
19
  import { LoadJCAMPModal } from '../modal/LoadJCAMPModal';
19
- import { useMetaInformationImportationModal } from '../modal/metaImportation';
20
+ import SaveAsModal from '../modal/SaveAsModal';
21
+ import { MetaImportationModal } from '../modal/metaImportation/MetaImportationModal';
20
22
  import { options } from './ToolTypes';
21
23
  import { EXPORT_MENU, IMPORT_MENU } from './toolbarMenu';
22
24
  function isPopoverToolItem(item) {
@@ -31,10 +33,13 @@ export default function ToolBar() {
31
33
  handleChangeOption(selectedOption);
32
34
  }, [handleChangeOption]);
33
35
  const openLoader = useLoader();
34
- const openMetaInformationModal = useMetaInformationImportationModal();
35
36
  const isExperimentalFeature = useCheckExperimentalFeature();
36
- const [isLoadJCAMPModalOpened, openLoadJCAMPModal, closeLoadJCAMPModal] = useOnOff(false);
37
- const [isPublicationStringModalOpened, openPublicationStringModal, closePublicationStringModal,] = useOnOff(false);
37
+ const { dialog, closeDialog, openDialog } = useDialogToggle({
38
+ loadJCAMP: false,
39
+ importPublicationString: false,
40
+ metaImportation: false,
41
+ saveAs: false,
42
+ });
38
43
  const verticalAlign = useVerticalAlign();
39
44
  const { fidCounter, ftCounter } = useDatumWithSpectraStatistics();
40
45
  const importMenu = isExperimentalFeature
@@ -58,20 +63,20 @@ export default function ToolBar() {
58
63
  type: 'APPLY_FFT_DIMENSION_2_FILTER',
59
64
  });
60
65
  }, [dispatch]);
61
- const { saveAsSVGHandler, saveAsPNGHandler, saveAsJSONHandler, saveToClipboardHandler, saveAsHandler, } = useExport();
66
+ const { saveAsSVGHandler, saveAsPNGHandler, saveAsJSONHandler, saveToClipboardHandler, } = useExport();
62
67
  function importHandler(data) {
63
68
  switch (data?.id) {
64
69
  case 'importFile':
65
70
  openLoader();
66
71
  break;
67
72
  case 'importJDX':
68
- openLoadJCAMPModal();
73
+ openDialog('loadJCAMP');
69
74
  break;
70
75
  case 'importPublicationString':
71
- openPublicationStringModal();
76
+ openDialog('importPublicationString');
72
77
  break;
73
78
  case 'importMetaInformation':
74
- openMetaInformationModal();
79
+ openDialog('metaImportation');
75
80
  break;
76
81
  default:
77
82
  }
@@ -88,7 +93,7 @@ export default function ToolBar() {
88
93
  saveAsJSONHandler();
89
94
  break;
90
95
  case 'advance_save':
91
- void saveAsHandler();
96
+ openDialog('saveAs');
92
97
  break;
93
98
  case 'copy':
94
99
  void saveToClipboardHandler();
@@ -139,7 +144,7 @@ export default function ToolBar() {
139
144
  title: options.multipleSpectraAnalysis.label,
140
145
  icon: _jsx(SvgNmrMultipleAnalysis, {}),
141
146
  checkOptions: { checkSpectrumType: false },
142
- condition: ftCounter > 1,
147
+ condition: ftCounter > 0,
143
148
  },
144
149
  {
145
150
  id: 'apodization',
@@ -226,7 +231,7 @@ export default function ToolBar() {
226
231
  onClick: alignSpectrumsVerticallyHandler,
227
232
  },
228
233
  ];
229
- return (_jsxs(_Fragment, { children: [_jsx(LoadJCAMPModal, { isOpen: isLoadJCAMPModalOpened, onCloseDialog: closeLoadJCAMPModal }), _jsx(ImportPublicationStringModal, { isOpen: isPublicationStringModalOpened, onClose: closePublicationStringModal }), _jsx(Toolbar, { vertical: true, children: toolItems.map((item) => {
234
+ return (_jsxs(_Fragment, { children: [_jsx(LoadJCAMPModal, { isOpen: dialog.loadJCAMP, onCloseDialog: closeDialog }), _jsx(ImportPublicationStringModal, { isOpen: dialog.importPublicationString, onClose: closeDialog }), _jsx(MetaImportationModal, { isOpen: dialog.metaImportation, onCloseDialog: closeDialog }), _jsx(SaveAsModal, { isOpen: dialog.saveAs, onCloseDialog: closeDialog }), _jsx(Toolbar, { vertical: true, children: toolItems.map((item) => {
230
235
  const { id, icon, title, checkOptions, condition } = item;
231
236
  const show = isButtonVisible(id, checkOptions) &&
232
237
  (condition === undefined || condition);
@@ -1,8 +1,19 @@
1
1
  import EE from 'eventemitter3';
2
+ import { BrushTrackerContext, ClickOptions } from '../EventsTrackers/BrushTracker';
2
3
  declare const Emitter: {
3
4
  on: (event: any, fn: any) => EE<string | symbol, any>;
4
5
  once: (event: any, fn: any) => EE<string | symbol, any>;
5
6
  off: (event: any, fn: any) => EE<string | symbol, any>;
6
7
  emit: (event: any, payload: any) => boolean;
7
8
  };
9
+ export type EventEmitterClickOptions = ClickOptions & {
10
+ xPPM: number;
11
+ };
12
+ interface UseEventOptions {
13
+ onBrushEnd?: (options: BrushTrackerContext & {
14
+ range: number[];
15
+ }) => void;
16
+ onClick?: (options: EventEmitterClickOptions) => void;
17
+ }
18
+ export declare function useEvent(options: UseEventOptions): void;
8
19
  export default Emitter;
@@ -1,4 +1,5 @@
1
1
  import EE from 'eventemitter3';
2
+ import { useEffect } from 'react';
2
3
  const eventEmitter = new EE();
3
4
  const Emitter = {
4
5
  on: (event, fn) => eventEmitter.on(event, fn),
@@ -7,4 +8,25 @@ const Emitter = {
7
8
  emit: (event, payload) => eventEmitter.emit(event, payload),
8
9
  };
9
10
  Object.freeze(Emitter);
11
+ export function useEvent(options) {
12
+ const { onBrushEnd, onClick } = options;
13
+ useEffect(() => {
14
+ function handle(event) {
15
+ onBrushEnd?.(event);
16
+ }
17
+ Emitter.on('brushEnd', handle);
18
+ return () => {
19
+ Emitter.off('brushEnd', handle);
20
+ };
21
+ }, [onBrushEnd]);
22
+ useEffect(() => {
23
+ function handle(event) {
24
+ onClick?.(event);
25
+ }
26
+ Emitter.on('mouseClick', handle);
27
+ return () => {
28
+ Emitter.off('mouseClick', handle);
29
+ };
30
+ }, [onClick]);
31
+ }
10
32
  export default Emitter;
@@ -1,40 +1,7 @@
1
1
  import { Spectrum1D } from 'nmr-load-save';
2
- import { Signal1D } from 'nmr-processing';
3
2
  interface RangeOptions {
4
3
  from: number;
5
4
  to: number;
6
5
  }
7
- export declare function createRangeObj({ from, to, absolute, signals, }: RangeOptions & {
8
- signals: Array<Omit<Signal1D, 'id'>>;
9
- absolute: number;
10
- }): {
11
- id: string;
12
- from: number;
13
- to: number;
14
- absolute: number;
15
- signals: {
16
- peaks?: import("nmr-processing").NMRPeak1D[] | undefined;
17
- kind?: string | undefined;
18
- assignment?: string | undefined;
19
- diaIDs?: string[] | undefined;
20
- integration?: number | undefined;
21
- multiplicity: string;
22
- nbAtoms?: number | undefined;
23
- js: import("nmr-processing").Jcoupling[];
24
- delta: number;
25
- atoms?: number[] | undefined;
26
- statistic?: {
27
- mean: number;
28
- sd: number;
29
- min: number;
30
- max: number;
31
- nb: number;
32
- } | undefined;
33
- originalDelta?: number | undefined;
34
- id: string;
35
- }[];
36
- kind: "signal";
37
- integration: number;
38
- };
39
6
  export declare function addRange(spectrum: Spectrum1D, options: RangeOptions): void;
40
7
  export {};
@@ -1,24 +1,11 @@
1
- import { v4 } from '@lukeed/uuid';
2
1
  import { xyIntegration } from 'ml-spectra-processing';
3
2
  import { mapRanges } from 'nmr-processing';
4
- import { DATUM_KIND } from '../../../constants/signalsKinds';
5
3
  import detectSignals from './detectSignals';
6
- export function createRangeObj({ from, to, absolute, signals, }) {
7
- return {
8
- id: v4(),
9
- from,
10
- to,
11
- absolute, // the real value,
12
- signals: signals.map((signal) => ({ id: v4(), ...signal })),
13
- kind: DATUM_KIND.signal,
14
- integration: 0,
15
- };
16
- }
17
4
  export function addRange(spectrum, options) {
18
5
  const { from, to } = options;
19
6
  const { x, re: y } = spectrum.data;
20
7
  const { nucleus, originFrequency: frequency } = spectrum.info;
21
- const absolute = xyIntegration({ x, y }, { from, to, reverse: true });
8
+ const absolute = xyIntegration({ x, y }, { from, to });
22
9
  const signals = detectSignals({ x, y }, {
23
10
  from,
24
11
  to,
@@ -32,7 +19,10 @@ export function addRange(spectrum, options) {
32
19
  signals,
33
20
  };
34
21
  try {
35
- spectrum.ranges.values = spectrum.ranges.values.concat(mapRanges([range], spectrum));
22
+ spectrum.ranges.values = spectrum.ranges.values.concat(
23
+ // TODO: Check this error.
24
+ // @ts-expect-error To be checked
25
+ mapRanges([range], spectrum));
36
26
  }
37
27
  catch (error) {
38
28
  reportError(error);
@@ -4,17 +4,18 @@ const defaultPeakPickingOptions = {
4
4
  shape: { kind: 'lorentzian' },
5
5
  realTopDetection: true,
6
6
  maxCriteria: true,
7
- smoothY: false,
7
+ smoothY: true,
8
+ broadWidth: 0.25,
9
+ broadRatio: 0.0025,
8
10
  integrationSum: 100,
9
- factorStd: 5,
10
- clean: true,
11
+ thresholdFactor: 5,
11
12
  sgOptions: { windowSize: 7, polynomial: 3 },
12
13
  };
13
14
  export default function autoRangesDetection(spectrum, options = {}) {
14
15
  // we calculate the noise but this could be improved
15
16
  let { re, x } = spectrum.data;
16
17
  const { originFrequency, nucleus } = spectrum.info;
17
- const { windowFromIndex, windowToIndex, peakPicking } = options;
18
+ const { windowFromIndex, windowToIndex, peakPicking, rangePicking } = options;
18
19
  const peakPickingOptions = {
19
20
  ...defaultPeakPickingOptions,
20
21
  ...peakPicking,
@@ -27,6 +28,7 @@ export default function autoRangesDetection(spectrum, options = {}) {
27
28
  frequencyCluster: 13,
28
29
  keepPeaks: true,
29
30
  clean: 0.3,
31
+ ...rangePicking,
30
32
  };
31
33
  if (windowFromIndex !== undefined && windowToIndex !== undefined) {
32
34
  x = x.slice(windowFromIndex, windowToIndex);
@@ -6,7 +6,7 @@ export function changeRange(spectrum, range) {
6
6
  const { x, re: y } = spectrum.data;
7
7
  const { originFrequency: frequency, nucleus } = spectrum.info;
8
8
  const index = spectrum.ranges.values.findIndex((i) => i.id === id);
9
- const absolute = xyIntegration({ x, y }, { from, to, reverse: true });
9
+ const absolute = xyIntegration({ x, y }, { from, to });
10
10
  const signals = detectSignals({ x, y }, {
11
11
  from,
12
12
  to,
@@ -4,7 +4,7 @@ import { getShiftX } from 'nmr-processing';
4
4
  export function detectRange(spectrum, options) {
5
5
  const { from, to } = options;
6
6
  const { x, re: y } = spectrum.data;
7
- const absolute = xyIntegration({ x, y }, { from, to, reverse: true });
7
+ const absolute = xyIntegration({ x, y }, { from, to });
8
8
  const min = xyMinYPoint({ x, y }, { from, to }).y;
9
9
  const max = xyMaxYPoint({ x, y }, { from, to }).y;
10
10
  const shiftX = getShiftX(spectrum);
@@ -3,14 +3,16 @@ import { SumParams } from '../SumManager';
3
3
  interface DetectRangesOptions {
4
4
  windowFromIndex?: number;
5
5
  windowToIndex?: number;
6
- peakPicking: {
7
- factorStd?: number;
8
- minMaxRatio?: number;
6
+ rangePicking: {
9
7
  integrationSum?: number;
10
8
  compile?: boolean;
11
9
  frequencyCluster?: number;
12
- clean?: boolean;
10
+ clean?: number;
13
11
  keepPeaks?: boolean;
12
+ };
13
+ peakPicking: {
14
+ thresholdFactor?: number;
15
+ minMaxRatio?: number;
14
16
  direction?: 'negative' | 'positive' | 'both';
15
17
  };
16
18
  impurities?: {
@@ -1,14 +1,24 @@
1
1
  import { DataXY } from 'cheminfo-types';
2
- export default function detectSignals(data: DataXY, options: {
2
+ export default function detectSignals(data: DataXY<Float64Array>, options: {
3
3
  from: number;
4
4
  to: number;
5
5
  nucleus: string;
6
6
  frequency: number;
7
7
  }): {
8
- multiplicity: any;
8
+ multiplicity: string;
9
9
  kind: string;
10
10
  delta: number;
11
- js: any;
11
+ js: never[];
12
+ peaks: import("ml-gsd").GSDPeakOptimized[];
13
+ diaIDs: never[];
14
+ }[] | {
15
+ multiplicity: string;
16
+ kind: string;
17
+ delta: any;
18
+ js: {
19
+ value: number;
20
+ multiplicity: "string";
21
+ }[];
12
22
  peaks: import("nmr-processing").NMRPeak1DWithShapeID[];
13
23
  diaIDs: never[];
14
24
  }[] | {
@@ -8,9 +8,15 @@ export default function detectSignals(data, options) {
8
8
  if (toIndex - fromIndex >= MAX_LENGTH) {
9
9
  const ranges = xyAutoRangesPicking(data, {
10
10
  peakPicking: {
11
+ sgOptions: {
12
+ windowSize: 7,
13
+ polynomial: 3,
14
+ },
11
15
  to,
12
16
  from,
13
17
  frequency,
18
+ broadRatio: 0.0025,
19
+ smoothY: true,
14
20
  },
15
21
  ranges: {
16
22
  symRatio: 2.5,
@@ -1,10 +1,20 @@
1
1
  import { DataXY } from 'cheminfo-types';
2
2
  import { NMRPeak1DWithShapeID } from 'nmr-processing';
3
- export declare function detectSignalsByMultipletAnalysis(data: DataXY, options: any): {
4
- multiplicity: any;
3
+ export declare function detectSignalsByMultipletAnalysis(data: DataXY<Float64Array>, options: any): {
4
+ multiplicity: string;
5
5
  kind: string;
6
6
  delta: number;
7
- js: any;
7
+ js: never[];
8
+ peaks: import("ml-gsd").GSDPeakOptimized[];
9
+ diaIDs: never[];
10
+ }[] | {
11
+ multiplicity: string;
12
+ kind: string;
13
+ delta: any;
14
+ js: {
15
+ value: number;
16
+ multiplicity: "string";
17
+ }[];
8
18
  peaks: NMRPeak1DWithShapeID[];
9
19
  diaIDs: never[];
10
20
  }[];