nmrium 0.63.1 → 0.64.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 (174) hide show
  1. package/lib/component/1d/BrushTracker1D.d.ts.map +1 -1
  2. package/lib/component/1d/BrushTracker1D.js +8 -1
  3. package/lib/component/1d/BrushTracker1D.js.map +1 -1
  4. package/lib/component/1d/PredictionErrorsNotations.d.ts +2 -0
  5. package/lib/component/1d/PredictionErrorsNotations.d.ts.map +1 -0
  6. package/lib/component/1d/PredictionErrorsNotations.js +112 -0
  7. package/lib/component/1d/PredictionErrorsNotations.js.map +1 -0
  8. package/lib/component/1d/SVGContent1D.d.ts.map +1 -1
  9. package/lib/component/1d/SVGContent1D.js +2 -1
  10. package/lib/component/1d/SVGContent1D.js.map +1 -1
  11. package/lib/component/2d/ft/Contours.d.ts.map +1 -1
  12. package/lib/component/2d/ft/Contours.js +3 -4
  13. package/lib/component/2d/ft/Contours.js.map +1 -1
  14. package/lib/component/2d/utilities/extractSpectrumSignals.d.ts +5 -3
  15. package/lib/component/2d/utilities/extractSpectrumSignals.d.ts.map +1 -1
  16. package/lib/component/2d/utilities/extractSpectrumSignals.js +3 -3
  17. package/lib/component/2d/utilities/extractSpectrumSignals.js.map +1 -1
  18. package/lib/component/2d/zones/SignalsGuideLines.d.ts.map +1 -1
  19. package/lib/component/2d/zones/SignalsGuideLines.js +74 -6
  20. package/lib/component/2d/zones/SignalsGuideLines.js.map +1 -1
  21. package/lib/component/EventsTrackers/BrushTracker.d.ts.map +1 -1
  22. package/lib/component/EventsTrackers/BrushTracker.js +2 -2
  23. package/lib/component/EventsTrackers/BrushTracker.js.map +1 -1
  24. package/lib/component/assignment/AssignmentProvider.d.ts.map +1 -1
  25. package/lib/component/assignment/AssignmentProvider.js +2 -1
  26. package/lib/component/assignment/AssignmentProvider.js.map +1 -1
  27. package/lib/component/assignment/AssignmentsContext.d.ts +5 -2
  28. package/lib/component/assignment/AssignmentsContext.d.ts.map +1 -1
  29. package/lib/component/assignment/AssignmentsContext.js +2 -1
  30. package/lib/component/assignment/AssignmentsContext.js.map +1 -1
  31. package/lib/component/elements/SVGGroup.js +1 -1
  32. package/lib/component/elements/SVGGroup.js.map +1 -1
  33. package/lib/component/elements/Sections.d.ts +1 -0
  34. package/lib/component/elements/Sections.d.ts.map +1 -1
  35. package/lib/component/elements/Sections.js +42 -7
  36. package/lib/component/elements/Sections.js.map +1 -1
  37. package/lib/component/elements/pdnd.cjs +12 -0
  38. package/lib/component/elements/pdnd.cjs.map +1 -0
  39. package/lib/component/elements/pdnd.d.cts +2 -0
  40. package/lib/component/elements/pdnd.d.cts.map +1 -0
  41. package/lib/component/hooks/useToolsFunctions.js +1 -1
  42. package/lib/component/hooks/useToolsFunctions.js.map +1 -1
  43. package/lib/component/main/InnerNMRiumContents.d.ts.map +1 -1
  44. package/lib/component/main/InnerNMRiumContents.js +3 -1
  45. package/lib/component/main/InnerNMRiumContents.js.map +1 -1
  46. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.d.ts.map +1 -1
  47. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.js +7 -4
  48. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.js.map +1 -1
  49. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +6 -5
  50. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js.map +1 -1
  51. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts +1 -1
  52. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts.map +1 -1
  53. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +3 -2
  54. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js.map +1 -1
  55. package/lib/component/panels/MoleculesPanel/Utilities.d.ts.map +1 -1
  56. package/lib/component/panels/MoleculesPanel/Utilities.js +2 -0
  57. package/lib/component/panels/MoleculesPanel/Utilities.js.map +1 -1
  58. package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts.map +1 -1
  59. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +17 -9
  60. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js.map +1 -1
  61. package/lib/component/panels/Panels.d.ts +0 -4
  62. package/lib/component/panels/Panels.d.ts.map +1 -1
  63. package/lib/component/panels/Panels.js +8 -14
  64. package/lib/component/panels/Panels.js.map +1 -1
  65. package/lib/component/panels/RangesPanel/RangesHeader.d.ts.map +1 -1
  66. package/lib/component/panels/RangesPanel/RangesHeader.js +5 -8
  67. package/lib/component/panels/RangesPanel/RangesHeader.js.map +1 -1
  68. package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.d.ts.map +1 -1
  69. package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.js +4 -1
  70. package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.js.map +1 -1
  71. package/lib/component/panels/extra/utilities/MultiplicityUtilities.d.ts +1 -1
  72. package/lib/component/panels/extra/utilities/MultiplicityUtilities.d.ts.map +1 -1
  73. package/lib/component/panels/filtersPanel/Filters/FiltersSectionsPanel.d.ts.map +1 -1
  74. package/lib/component/panels/filtersPanel/Filters/FiltersSectionsPanel.js +7 -1
  75. package/lib/component/panels/filtersPanel/Filters/FiltersSectionsPanel.js.map +1 -1
  76. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.d.ts +1 -1
  77. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.d.ts.map +1 -1
  78. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.js +15 -17
  79. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.js.map +1 -1
  80. package/lib/component/panels/hooks/useTogglePanel.d.ts.map +1 -1
  81. package/lib/component/panels/hooks/useTogglePanel.js +4 -3
  82. package/lib/component/panels/hooks/useTogglePanel.js.map +1 -1
  83. package/lib/component/reducer/Reducer.d.ts.map +1 -1
  84. package/lib/component/reducer/Reducer.js +2 -0
  85. package/lib/component/reducer/Reducer.js.map +1 -1
  86. package/lib/component/reducer/actions/FiltersActions.d.ts +7 -2
  87. package/lib/component/reducer/actions/FiltersActions.d.ts.map +1 -1
  88. package/lib/component/reducer/actions/FiltersActions.js +56 -26
  89. package/lib/component/reducer/actions/FiltersActions.js.map +1 -1
  90. package/lib/component/reducer/actions/InsetActions.d.ts.map +1 -1
  91. package/lib/component/reducer/actions/InsetActions.js +1 -5
  92. package/lib/component/reducer/actions/InsetActions.js.map +1 -1
  93. package/lib/component/reducer/actions/RangesActions.d.ts +3 -1
  94. package/lib/component/reducer/actions/RangesActions.d.ts.map +1 -1
  95. package/lib/component/reducer/actions/RangesActions.js +7 -14
  96. package/lib/component/reducer/actions/RangesActions.js.map +1 -1
  97. package/lib/component/reducer/actions/ToolsActions.d.ts.map +1 -1
  98. package/lib/component/reducer/actions/ToolsActions.js +2 -2
  99. package/lib/component/reducer/actions/ToolsActions.js.map +1 -1
  100. package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +3 -2
  101. package/lib/component/reducer/helper/ZoomHistoryManager.d.ts.map +1 -1
  102. package/lib/component/reducer/helper/ZoomHistoryManager.js +17 -8
  103. package/lib/component/reducer/helper/ZoomHistoryManager.js.map +1 -1
  104. package/lib/component/reducer/preferences/actions/togglePanel.d.ts.map +1 -1
  105. package/lib/component/reducer/preferences/actions/togglePanel.js +11 -6
  106. package/lib/component/reducer/preferences/actions/togglePanel.js.map +1 -1
  107. package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -1
  108. package/lib/component/reducer/preferences/preferencesReducer.d.ts.map +1 -1
  109. package/lib/component/reducer/preferences/preferencesReducer.js.map +1 -1
  110. package/lib/component/toolbar/ToolBar.js +3 -2
  111. package/lib/component/toolbar/ToolBar.js.map +1 -1
  112. package/lib/component/toolbar/ToolTypes.js +1 -1
  113. package/lib/component/toolbar/ToolTypes.js.map +1 -1
  114. package/lib/component/workspaces/exercise.js +1 -1
  115. package/lib/component/workspaces/prediction.js +1 -1
  116. package/lib/component/workspaces/prediction.js.map +1 -1
  117. package/lib/component/workspaces/workspaceDefaultProperties.js +1 -1
  118. package/lib/data/PredictionManager.d.ts.map +1 -1
  119. package/lib/data/PredictionManager.js +1 -0
  120. package/lib/data/PredictionManager.js.map +1 -1
  121. package/lib/data/data2d/Spectrum2D/contours.d.ts.map +1 -1
  122. package/lib/data/data2d/Spectrum2D/contours.js +6 -4
  123. package/lib/data/data2d/Spectrum2D/contours.js.map +1 -1
  124. package/lib/data/data2d/Spectrum2D/initiateDatum2D.d.ts.map +1 -1
  125. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +22 -10
  126. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js.map +1 -1
  127. package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts.map +1 -1
  128. package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts.map +1 -1
  129. package/lib/data/types/data1d/index.js +1 -1
  130. package/lib/data/types/data1d/index.js.map +1 -1
  131. package/lib/versionInfo.js +1 -1
  132. package/package.json +22 -21
  133. package/src/component/1d/BrushTracker1D.tsx +8 -1
  134. package/src/component/1d/PredictionErrorsNotations.tsx +209 -0
  135. package/src/component/1d/SVGContent1D.tsx +2 -0
  136. package/src/component/2d/ft/Contours.tsx +3 -11
  137. package/src/component/2d/utilities/extractSpectrumSignals.ts +12 -9
  138. package/src/component/2d/zones/SignalsGuideLines.tsx +107 -11
  139. package/src/component/EventsTrackers/BrushTracker.tsx +2 -3
  140. package/src/component/assignment/AssignmentProvider.tsx +2 -1
  141. package/src/component/assignment/AssignmentsContext.ts +7 -2
  142. package/src/component/elements/SVGGroup.tsx +2 -2
  143. package/src/component/elements/Sections.tsx +103 -19
  144. package/src/component/elements/pdnd.cts +9 -0
  145. package/src/component/hooks/useToolsFunctions.ts +1 -1
  146. package/src/component/main/InnerNMRiumContents.tsx +3 -1
  147. package/src/component/modal/setting/settings-tabs/DatabasesTabContent.tsx +12 -7
  148. package/src/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.tsx +11 -5
  149. package/src/component/panels/MoleculesPanel/MoleculePanelHeader.tsx +32 -32
  150. package/src/component/panels/MoleculesPanel/Utilities.ts +2 -0
  151. package/src/component/panels/MoleculesPanel/useAtomAssignment.tsx +29 -8
  152. package/src/component/panels/Panels.tsx +9 -24
  153. package/src/component/panels/RangesPanel/RangesHeader.tsx +14 -21
  154. package/src/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.tsx +11 -1
  155. package/src/component/panels/filtersPanel/Filters/FiltersSectionsPanel.tsx +9 -0
  156. package/src/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.tsx +16 -18
  157. package/src/component/panels/hooks/useTogglePanel.ts +4 -3
  158. package/src/component/reducer/Reducer.ts +2 -0
  159. package/src/component/reducer/actions/FiltersActions.ts +86 -40
  160. package/src/component/reducer/actions/InsetActions.ts +1 -5
  161. package/src/component/reducer/actions/RangesActions.ts +10 -13
  162. package/src/component/reducer/actions/ToolsActions.ts +1 -2
  163. package/src/component/reducer/helper/ZoomHistoryManager.ts +20 -9
  164. package/src/component/reducer/preferences/actions/togglePanel.ts +10 -6
  165. package/src/component/reducer/preferences/preferencesReducer.ts +11 -1
  166. package/src/component/toolbar/ToolBar.tsx +2 -2
  167. package/src/component/toolbar/ToolTypes.ts +1 -1
  168. package/src/component/workspaces/exercise.ts +1 -1
  169. package/src/component/workspaces/prediction.ts +1 -1
  170. package/src/component/workspaces/workspaceDefaultProperties.ts +1 -1
  171. package/src/data/PredictionManager.ts +1 -0
  172. package/src/data/data2d/Spectrum2D/contours.ts +8 -4
  173. package/src/data/data2d/Spectrum2D/initiateDatum2D.ts +34 -16
  174. package/src/versionInfo.ts +1 -1
@@ -5,7 +5,6 @@ import { usePanelOpenState } from '../Panels.js';
5
5
 
6
6
  export function useTogglePanel() {
7
7
  const { dispatch, current } = usePreferences();
8
- const { setPanelOpenState } = usePanelOpenState();
9
8
  const { isSplitPaneOpen, openSplitPane } = usePanelOpenState();
10
9
 
11
10
  function togglePanel(id: keyof NMRiumPanelPreferences) {
@@ -15,8 +14,10 @@ export function useTogglePanel() {
15
14
  openSplitPane();
16
15
 
17
16
  if ((!isSplitPaneOpen && !flag) || isSplitPaneOpen) {
18
- setPanelOpenState(id, !flag);
19
- dispatch({ type: 'TOGGLE_PANEL', payload: { id } });
17
+ dispatch({
18
+ type: 'TOGGLE_PANEL',
19
+ payload: { id, options: { display: undefined, open: !flag } },
20
+ });
20
21
  }
21
22
  }
22
23
 
@@ -574,6 +574,8 @@ function innerSpectrumReducer(draft: Draft<State>, action: Action) {
574
574
  return FiltersActions.handleApplyAutoPhaseCorrectionTwoDimensionsFilter(
575
575
  draft,
576
576
  );
577
+ case 'REORDER_FILTERS':
578
+ return FiltersActions.handleReorderFilters(draft, action);
577
579
  case 'CHANGE_SPECTRUM_VISIBILITY':
578
580
  return SpectraActions.handleChangeSpectrumVisibilityById(draft, action);
579
581
  case 'CHANGE_SPECTRA_VISIBILITY_BY_NUCLEUS':
@@ -26,7 +26,10 @@ import { isSpectrum1D } from '../../../data/data1d/Spectrum1D/index.js';
26
26
  import { isFid1DSpectrum } from '../../../data/data1d/Spectrum1D/isSpectrum1D.js';
27
27
  import { getProjection } from '../../../data/data2d/Spectrum2D/getMissingProjection.js';
28
28
  import { isSpectrum2D } from '../../../data/data2d/Spectrum2D/index.js';
29
- import { isFid2DSpectrum } from '../../../data/data2d/Spectrum2D/isSpectrum2D.js';
29
+ import {
30
+ isFid2DSpectrum,
31
+ isFt2DSpectrum,
32
+ } from '../../../data/data2d/Spectrum2D/isSpectrum2D.js';
30
33
  import type { ExclusionZone } from '../../../data/types/data1d/ExclusionZone.js';
31
34
  import { getXScale } from '../../1d/utilities/scale.js';
32
35
  import { get2DXScale, get2DYScale } from '../../2d/utilities/scale.js';
@@ -56,6 +59,7 @@ import type { ActionType } from '../types/ActionType.js';
56
59
  import { get2DDomain, setDomain, setMode } from './DomainActions.js';
57
60
  import { changeSpectrumVerticalAlignment } from './PreferencesActions.js';
58
61
  import { activateTool, resetSelectedTool } from './ToolsActions.js';
62
+ import { getDefaultContoursLevel } from '../../../data/data2d/Spectrum2D/contours.js';
59
63
 
60
64
  const {
61
65
  fft,
@@ -213,6 +217,10 @@ type DeletePhaseCorrectionTrace = ActionType<
213
217
  'DELETE_PHASE_CORRECTION_TRACE',
214
218
  { id: string }
215
219
  >;
220
+ type ReorderFiltersAction = ActionType<
221
+ 'REORDER_FILTERS',
222
+ { sourceId: string; targetId: string }
223
+ >;
216
224
 
217
225
  type SetOneDimensionPhaseCorrectionPivotPoint = ActionType<
218
226
  'SET_ONE_DIMENSION_PIVOT_POINT',
@@ -254,6 +262,7 @@ export type FiltersActions =
254
262
  | SetOneDimensionPhaseCorrectionPivotPoint
255
263
  | SetTwoDimensionPhaseCorrectionPivotPoint
256
264
  | ManualTwoDimensionsPhaseCorrectionFilterAction
265
+ | ReorderFiltersAction
257
266
  | ActionType<
258
267
  | 'APPLY_FFT_FILTER'
259
268
  | 'APPLY_FFT_DIMENSION_1_FILTER'
@@ -466,15 +475,13 @@ function rollbackSpectrumByFilter(
466
475
  reapplyFilters(spectrum, filters);
467
476
 
468
477
  draft.tempData = current(draft).data.slice();
469
- draft.tempData[index] = spectrum;
478
+ draft.tempData[index] = structuredClone(spectrum);
470
479
 
471
480
  // apply the current Filters
472
481
  if (applyFilter) {
473
482
  executeFilter(spectrum, spectrum.filters[filterIndex]);
474
483
  }
475
484
 
476
- spectrum = structuredClone(spectrum);
477
-
478
485
  if (tempRollback) {
479
486
  reapplyFilters(spectrum);
480
487
  updateDomainOptions = getFilterDomain(spectrum, {
@@ -496,16 +503,24 @@ function rollbackSpectrumByFilter(
496
503
  // re-implement all filters and rest all view property that related to filters
497
504
  if (reset) {
498
505
  if (filterIndex !== -1 && spectrum.filters.length > 0) {
506
+ // A filter exists, reset the domain based on the filters from the current filter index to the last one
499
507
  updateDomainOptions = getFilterDomain(spectrum, {
500
508
  startIndex: filterIndex,
501
509
  lastIndex: spectrum.filters.length - 1,
502
510
  });
503
511
  } else if (toolData.activeFilterID) {
512
+ // No filter exists yet, but there is an active one in this case reset both x and y domain
513
+
504
514
  updateDomainOptions = { updateXDomain: true, updateYDomain: true };
515
+ } else if (searchBy === 'name' && key) {
516
+ // No filter exists yet and no active filter, reset the x and y domain based on the current filter domain rules
517
+ const { updateXDomain, updateYDomain } =
518
+ getFilterUpdateDomainRules(key);
519
+ updateDomainOptions = { updateXDomain, updateYDomain };
505
520
  } else {
521
+ //otherwise do not reset the domain
506
522
  updateDomainOptions = { updateXDomain: false, updateYDomain: false };
507
523
  }
508
-
509
524
  toolData.activeFilterID = null;
510
525
  draft.tempData = null;
511
526
 
@@ -1224,7 +1239,16 @@ function handleApplyFFTFilter(draft: Draft<State>) {
1224
1239
  draft.toolOptions.selectedTool = 'zoom';
1225
1240
  }
1226
1241
 
1227
- function handleApplyFFtDimension1Filter(draft: Draft<State>) {
1242
+ function applyFFTTwoDimensionFilter(
1243
+ draft: Draft<State>,
1244
+ {
1245
+ filterName,
1246
+ domainUpdateRules,
1247
+ }: {
1248
+ filterName: 'fftDimension1' | 'fftDimension2';
1249
+ domainUpdateRules: FilterDomainUpdateRules;
1250
+ },
1251
+ ) {
1228
1252
  const activeSpectrum = getActiveSpectrum(draft);
1229
1253
 
1230
1254
  if (!activeSpectrum) {
@@ -1234,46 +1258,24 @@ function handleApplyFFtDimension1Filter(draft: Draft<State>) {
1234
1258
  const { index } = activeSpectrum;
1235
1259
  const activeFilterIndex = getActiveFilterIndex(draft);
1236
1260
 
1237
- //apply filter into the spectrum
1238
- Filters2DManager.applyFilters(
1239
- activeFilterIndex !== -1 ? draft.tempData[index] : draft.data[index],
1240
- [{ name: 'fftDimension1', value: {} }],
1241
- );
1261
+ const targetSpectrum =
1262
+ activeFilterIndex !== -1 ? draft.tempData[index] : draft.data[index];
1263
+
1264
+ Filters2DManager.applyFilters(targetSpectrum, [
1265
+ { name: filterName, value: {} },
1266
+ ]);
1242
1267
 
1243
1268
  if (activeFilterIndex !== -1) {
1244
1269
  draft.data[index] = draft.tempData[index];
1245
1270
  }
1246
1271
 
1247
- updateView(draft, fftDimension1.domainUpdateRules);
1248
-
1249
- //clear zoom history
1250
- draft.zoom.history[draft.view.spectra.activeTab] = [];
1251
-
1252
- draft.toolOptions.selectedOptionPanel = null;
1253
- draft.toolOptions.selectedTool = 'zoom';
1254
- }
1255
-
1256
- function handleApplyFFtDimension2Filter(draft: Draft<State>) {
1257
- const activeSpectrum = getActiveSpectrum(draft);
1258
-
1259
- if (!activeSpectrum) {
1260
- return;
1261
- }
1262
-
1263
- const { index } = activeSpectrum;
1264
- const activeFilterIndex = getActiveFilterIndex(draft);
1265
-
1266
- //apply filter into the spectrum
1267
- Filters2DManager.applyFilters(
1268
- activeFilterIndex !== -1 ? draft.tempData[index] : draft.data[index],
1269
- [{ name: 'fftDimension2', value: {} }],
1270
- );
1272
+ const spectrum = draft.data[index];
1271
1273
 
1272
- if (activeFilterIndex !== -1) {
1273
- draft.data[index] = draft.tempData[index];
1274
+ if (isFt2DSpectrum(spectrum)) {
1275
+ spectrum.display.contourOptions = getDefaultContoursLevel(spectrum);
1274
1276
  }
1275
1277
 
1276
- updateView(draft, fftDimension2.domainUpdateRules);
1278
+ updateView(draft, domainUpdateRules);
1277
1279
 
1278
1280
  //clear zoom history
1279
1281
  draft.zoom.history[draft.view.spectra.activeTab] = [];
@@ -1282,6 +1284,20 @@ function handleApplyFFtDimension2Filter(draft: Draft<State>) {
1282
1284
  draft.toolOptions.selectedTool = 'zoom';
1283
1285
  }
1284
1286
 
1287
+ function handleApplyFFtDimension1Filter(draft: Draft<State>) {
1288
+ applyFFTTwoDimensionFilter(draft, {
1289
+ filterName: 'fftDimension1',
1290
+ domainUpdateRules: fftDimension1.domainUpdateRules,
1291
+ });
1292
+ }
1293
+
1294
+ function handleApplyFFtDimension2Filter(draft: Draft<State>) {
1295
+ applyFFTTwoDimensionFilter(draft, {
1296
+ filterName: 'fftDimension2',
1297
+ domainUpdateRules: fftDimension2.domainUpdateRules,
1298
+ });
1299
+ }
1300
+
1285
1301
  //action
1286
1302
  function handleApplyManualPhaseCorrectionFilter(
1287
1303
  draft: Draft<State>,
@@ -1914,7 +1930,7 @@ function handleCalculateManualTwoDimensionPhaseCorrection(
1914
1930
  }
1915
1931
 
1916
1932
  const { index } = activeSpectrum;
1917
- const spectrum = draft.tempData[index];
1933
+ const spectrum = structuredClone(current(draft).tempData[index]);
1918
1934
  const datum = draft.data[index];
1919
1935
 
1920
1936
  if (!isSpectrum2D(datum) || !spectrum) {
@@ -1923,7 +1939,8 @@ function handleCalculateManualTwoDimensionPhaseCorrection(
1923
1939
 
1924
1940
  const filterOptions = getTwoDimensionsPhaseCorrectionOptions(draft);
1925
1941
 
1926
- phaseCorrectionTwoDimensions.apply(datum, filterOptions);
1942
+ phaseCorrectionTwoDimensions.apply(spectrum, filterOptions);
1943
+ draft.data[index].data = spectrum.data;
1927
1944
  }
1928
1945
 
1929
1946
  function getTwoDimensionsPhaseCorrectionOptions(draft: Draft<State>) {
@@ -1997,6 +2014,34 @@ function handleApplyAutoPhaseCorrectionTwoDimensionsFilter(
1997
2014
  updateView(draft, phaseCorrectionTwoDimensions.domainUpdateRules);
1998
2015
  }
1999
2016
 
2017
+ function handleReorderFilters(
2018
+ draft: Draft<State>,
2019
+ action: ReorderFiltersAction,
2020
+ ) {
2021
+ const { sourceId, targetId } = action.payload;
2022
+ const spectrum = getSpectrum(draft);
2023
+
2024
+ if (!spectrum) {
2025
+ return;
2026
+ }
2027
+
2028
+ const filters = spectrum.filters;
2029
+
2030
+ const sourceIndex = filters.findIndex((filter) => filter.name === sourceId);
2031
+ const targetIndex = filters.findIndex((filter) => filter.name === targetId);
2032
+
2033
+ if (sourceIndex === -1 || targetIndex === -1) return;
2034
+
2035
+ const sourceFilter = filters[sourceIndex];
2036
+ filters.splice(sourceIndex, 1);
2037
+ filters.splice(targetIndex, 0, sourceFilter);
2038
+ if (isSpectrum1D(spectrum)) {
2039
+ Filters1DManager.reapplyFilters(spectrum);
2040
+ } else {
2041
+ Filters2DManager.reapplyFilters(spectrum);
2042
+ }
2043
+ }
2044
+
2000
2045
  export {
2001
2046
  handleShiftSpectrumAlongXAxis,
2002
2047
  handleApplyZeroFillingFilter,
@@ -2040,4 +2085,5 @@ export {
2040
2085
  handleToggleAddTracesToBothDirections,
2041
2086
  handleApplyAutoPhaseCorrectionTwoDimensionsFilter,
2042
2087
  handleApplyExclusionZone,
2088
+ handleReorderFilters,
2043
2089
  };
@@ -344,12 +344,8 @@ function handleInsetZoomOut(draft: Draft<State>, action: ZoomOutInsetAction) {
344
344
 
345
345
  if (!inset) return;
346
346
  const originXDomain = draft.originDomain.xDomains[inset.spectrumKey];
347
- const originYDomain = draft.originDomain.yDomains[inset.spectrumKey];
348
347
 
349
- const pop = preparePop(inset.zoomHistory, {
350
- xDomain: originXDomain,
351
- yDomain: originYDomain,
352
- });
348
+ const pop = preparePop(inset.zoomHistory);
353
349
 
354
350
  switch (zoomType) {
355
351
  case ZOOM_TYPES.HORIZONTAL: {
@@ -87,6 +87,7 @@ type DeleteSignalAction = ActionType<'DELETE_1D_SIGNAL', DeleteSignalProps>;
87
87
 
88
88
  interface UnlinkRangeProps {
89
89
  rangeKey?: string;
90
+ spectrumId?: string; // If not specified, the currently active spectrum will be used by default.
90
91
  signalIndex?: number;
91
92
  }
92
93
  type UnlinkRangeAction = ActionType<'UNLINK_RANGE', UnlinkRangeProps>;
@@ -95,6 +96,7 @@ type AssignRangeAction = ActionType<
95
96
  'ASSIGN_RANGE',
96
97
  {
97
98
  keys: TargetAssignKeys;
99
+ spectrumId?: string;
98
100
  } & Required<Pick<Range, 'diaIDs' | 'nbAtoms'>>
99
101
  >;
100
102
  type ResizeRangeAction = ActionType<
@@ -191,6 +193,7 @@ function getRangeByIndex(draft: Draft<State>, spectrumIndex, rangeID) {
191
193
  (range) => range.id === rangeID,
192
194
  );
193
195
  }
196
+
194
197
  function getRange(spectrum: Spectrum1D, rangeID: string) {
195
198
  return spectrum.ranges.values.findIndex((range) => range.id === rangeID);
196
199
  }
@@ -399,12 +402,9 @@ function handleDeleteSignal(draft: Draft<State>, action: DeleteSignalAction) {
399
402
  deleteSignal1D(draft, action.payload);
400
403
  }
401
404
 
402
- function unlinkRange(draft: Draft<State>, options?: UnlinkRangeProps) {
403
- const activeSpectrum = getActiveSpectrum(draft);
404
-
405
- if (!activeSpectrum) return null;
406
- const { index } = activeSpectrum;
407
- const spectrum = draft.data[index];
405
+ function unlinkRange(draft: Draft<State>, options: UnlinkRangeProps = {}) {
406
+ const { spectrumId } = options;
407
+ const spectrum = getSpectrum(draft, spectrumId);
408
408
 
409
409
  if (!isSpectrum1D(spectrum)) return;
410
410
 
@@ -412,7 +412,7 @@ function unlinkRange(draft: Draft<State>, options?: UnlinkRangeProps) {
412
412
  const ranges = spectrum.ranges.values;
413
413
 
414
414
  if (rangeKey) {
415
- const rangeIndex = getRangeByIndex(draft, index, rangeKey);
415
+ const rangeIndex = getRange(spectrum, rangeKey);
416
416
  const unlinkType = signalIndex === -1 ? 'range' : 'signal';
417
417
  ranges[rangeIndex] = unlink(ranges[rangeIndex], {
418
418
  unlinkType,
@@ -433,14 +433,11 @@ function handleUnlinkRange(draft: Draft<State>, action: UnlinkRangeAction) {
433
433
 
434
434
  //action
435
435
  function handleAssignRange(draft: Draft<State>, action: AssignRangeAction) {
436
- const activeSpectrum = getActiveSpectrum(draft);
437
- if (!activeSpectrum?.id) return;
438
- const { index } = activeSpectrum;
439
- const spectrum = draft.data[index];
436
+ const { keys, diaIDs, nbAtoms, spectrumId } = action.payload;
440
437
 
441
- if (!isSpectrum1D(spectrum)) return;
438
+ const spectrum = getSpectrum(draft, spectrumId);
442
439
 
443
- const { keys, diaIDs, nbAtoms } = action.payload;
440
+ if (!spectrum || !isSpectrum1D(spectrum)) return;
444
441
 
445
442
  if (keys.length === 1) {
446
443
  const [{ index }] = keys;
@@ -470,11 +470,10 @@ function handleZoom(draft: Draft<State>, action: ZoomAction) {
470
470
  function zoomOut(draft: Draft<State>, action: ZoomOutAction) {
471
471
  if (draft?.data.length > 0) {
472
472
  const { zoomType, trackID } = action?.payload || {};
473
- const { xDomain, yDomain } = draft.originDomain;
473
+ const { xDomain } = draft.originDomain;
474
474
  const zoomHistory = zoomHistoryManager(
475
475
  draft.zoom.history,
476
476
  draft.view.spectra.activeTab,
477
- { xDomain, yDomain },
478
477
  );
479
478
 
480
479
  if (draft.displayerMode === '1D') {
@@ -12,6 +12,7 @@ export type ZoomHistory = Record<string, HistoryItem[]>;
12
12
  interface BaseZoomHistoryManager {
13
13
  historyStack: HistoryItem[];
14
14
  push: (value: HistoryItem) => void;
15
+ setBase: (value: HistoryItem) => void;
15
16
  pop: () => HistoryItem;
16
17
  getLast: () => HistoryItem;
17
18
  }
@@ -22,19 +23,19 @@ interface ZoomHistoryManager extends BaseZoomHistoryManager {
22
23
  export default function zoomHistoryManager(
23
24
  zoomHistory: ZoomHistory,
24
25
  nucleus: string,
25
- baseZoom?: HistoryItem,
26
26
  ): ZoomHistoryManager {
27
27
  if (!zoomHistory[nucleus] && !Array.isArray(zoomHistory[nucleus])) {
28
28
  zoomHistory[nucleus] = [];
29
29
  }
30
30
  const history = zoomHistory[nucleus];
31
31
 
32
+ const setBase = prepareSetBase(history);
32
33
  const push = preparePush(history);
33
- const pop = preparePop(history, baseZoom);
34
+ const pop = preparePop(history);
34
35
  const getLast = prepareGetLast(history);
35
36
  const clear = () => (zoomHistory[nucleus] = []);
36
37
 
37
- return { historyStack: history, push, pop, getLast, clear };
38
+ return { historyStack: history, push, pop, getLast, clear, setBase };
38
39
  }
39
40
 
40
41
  function preparePush(historyStack) {
@@ -43,18 +44,26 @@ function preparePush(historyStack) {
43
44
  };
44
45
  }
45
46
 
46
- function popZoomHistory(historyStack, baseZoom?: HistoryItem) {
47
+ function prepareSetBase(historyStack) {
48
+ return (val: HistoryItem) => {
49
+ if (historyStack.length === 0) {
50
+ historyStack[0] = val;
51
+ }
52
+ };
53
+ }
54
+
55
+ function popZoomHistory(historyStack) {
47
56
  const val = historyStack.pop();
48
57
 
49
- if (val && historyStack.length === 0) {
50
- return baseZoom || null;
58
+ if (historyStack.length === 0) {
59
+ return null;
51
60
  }
52
61
 
53
62
  return val ? historyStack.at(-1) : null;
54
63
  }
55
64
 
56
- export function preparePop(historyStack, baseZoom?: HistoryItem) {
57
- return () => popZoomHistory(historyStack, baseZoom);
65
+ export function preparePop(historyStack) {
66
+ return () => popZoomHistory(historyStack);
58
67
  }
59
68
 
60
69
  function prepareGetLast(historyStack) {
@@ -74,9 +83,11 @@ export function addToBrushHistory(
74
83
 
75
84
  const brushHistory = zoomHistoryManager(
76
85
  draft.zoom.history,
77
-
78
86
  draft.view.spectra.activeTab,
79
87
  );
88
+
89
+ brushHistory.setBase({ xDomain: draft.xDomain, yDomain: draft.yDomain });
90
+
80
91
  switch (axis) {
81
92
  case 'XY':
82
93
  draft.xDomain = xDomain;
@@ -12,19 +12,23 @@ export function togglePanel(
12
12
  action: TogglePanelAction,
13
13
  ) {
14
14
  const currentWorkspacePreferences = getActiveWorkspace(draft);
15
- const { id } = action.payload || {};
15
+ const { id, options } = action.payload || {};
16
16
 
17
17
  if (!id) return;
18
18
 
19
19
  const panels = currentWorkspacePreferences.display.panels || {};
20
20
 
21
- const existingPanel: PanelPreferencesType = panels[id];
21
+ const existingPanel: PanelPreferencesType = { ...panels[id] };
22
22
 
23
+ for (const [key, value] of Object.entries(options)) {
24
+ if (value === undefined) {
25
+ existingPanel[key] = !existingPanel[key];
26
+ } else {
27
+ existingPanel[key] = value;
28
+ }
29
+ }
23
30
  currentWorkspacePreferences.display.panels = {
24
31
  ...panels,
25
- [id]: {
26
- ...existingPanel,
27
- display: existingPanel ? !existingPanel.display : true,
28
- },
32
+ [id]: existingPanel,
29
33
  };
30
34
  }
@@ -3,6 +3,7 @@ import type {
3
3
  ExportPreferences,
4
4
  ExportSettings,
5
5
  MultipleSpectraAnalysisPreferences,
6
+ PanelPreferencesType,
6
7
  PrintPageOptions,
7
8
  Workspace,
8
9
  WorkSpaceSource,
@@ -48,6 +49,7 @@ import { setWorkspace } from './actions/setWorkspace.js';
48
49
  import { toggleInformationBlock } from './actions/toggleInformationBlock.js';
49
50
  import { togglePanel } from './actions/togglePanel.js';
50
51
  import { mapWorkspaces } from './utilities/mapWorkspaces.js';
52
+ import type { FilterType } from '../../utility/filterType.js';
51
53
 
52
54
  const LOCAL_STORAGE_SETTINGS_KEY = 'nmr-general-settings';
53
55
 
@@ -148,7 +150,15 @@ export type ChangePeaksLabelPositionAction = ActionType<
148
150
  }
149
151
  >;
150
152
 
151
- export type TogglePanelAction = ActionType<'TOGGLE_PANEL', { id: string }>;
153
+ export type TogglePanelAction = ActionType<
154
+ 'TOGGLE_PANEL',
155
+ {
156
+ id: string;
157
+ options: Partial<
158
+ Record<keyof FilterType<Required<PanelPreferencesType>, boolean>, boolean>
159
+ >;
160
+ }
161
+ >;
152
162
 
153
163
  type PreferencesActions =
154
164
  | InitPreferencesAction
@@ -21,9 +21,9 @@ import {
21
21
  FaExpand,
22
22
  FaFileExport,
23
23
  FaFileImport,
24
- FaSearchPlus,
25
24
  } from 'react-icons/fa';
26
25
  import { PiKnifeBold, PiSelectionPlusDuotone } from 'react-icons/pi';
26
+ import { TbZoom } from 'react-icons/tb';
27
27
  import type { ToolbarItemProps, TooltipItem } from 'react-science/ui';
28
28
  import { Toolbar, TooltipHelpContent } from 'react-science/ui';
29
29
 
@@ -226,7 +226,7 @@ export default function ToolBar() {
226
226
  ],
227
227
  style: { minWidth: '300px' },
228
228
  },
229
- icon: <FaSearchPlus />,
229
+ icon: <TbZoom strokeWidth={3} />,
230
230
  },
231
231
  {
232
232
  id: 'zoomOut',
@@ -37,7 +37,7 @@ type RecordOptions = Record<Tool, ToolOptionItem>;
37
37
  export const options: RecordOptions = {
38
38
  zoom: {
39
39
  id: 'zoom',
40
- label: 'Zoom in',
40
+ label: 'Zoom in / out',
41
41
  hasOptionPanel: false,
42
42
  isFilter: false,
43
43
  isToggle: true,
@@ -29,7 +29,7 @@ export const exercise: InnerWorkspace = {
29
29
  },
30
30
  },
31
31
  general: {
32
- dimmedSpectraOpacity: 0.1,
32
+ dimmedSpectraOpacity: 0.4,
33
33
  verticalSplitterPosition: '440px',
34
34
  verticalSplitterCloseThreshold: 600,
35
35
  spectraRendering: 'auto',
@@ -19,7 +19,7 @@ export const prediction: InnerWorkspace = {
19
19
  hideWorkspaces: true,
20
20
  },
21
21
  panels: {
22
- spectraPanel: { display: true, visible: true },
22
+ spectraPanel: { display: true, visible: true, open: false },
23
23
  rangesPanel: { display: true, visible: true },
24
24
  zonesPanel: { display: true, visible: true },
25
25
  predictionPanel: { display: true, visible: true, open: true },
@@ -63,7 +63,7 @@ export const workspaceDefaultProperties: Required<WorkspacePreferences> = {
63
63
  },
64
64
 
65
65
  general: {
66
- dimmedSpectraOpacity: 0.1,
66
+ dimmedSpectraOpacity: 0.4,
67
67
  verticalSplitterPosition: '560px',
68
68
  verticalSplitterCloseThreshold: 600,
69
69
  spectraRendering: 'auto',
@@ -80,6 +80,7 @@ export const FREQUENCIES: Array<{ value: number; label: string }> = [
80
80
  { value: 90, label: '90 MHz' },
81
81
  { value: 100, label: '100 MHz' },
82
82
  { value: 200, label: '200 MHz' },
83
+ { value: 250, label: '250 MHz' },
83
84
  { value: 300, label: '300 MHz' },
84
85
  { value: 400, label: '400 MHz' },
85
86
  { value: 500, label: '500 MHz' },
@@ -61,17 +61,21 @@ function getDefaultContoursLevel(spectrum: Spectrum2D, quadrant = 'rr') {
61
61
  Math.abs(quadrantData.minZ),
62
62
  Math.abs(quadrantData.maxZ),
63
63
  );
64
- const value = 3 * xMaxAbsoluteValue([positive, negative]);
65
- const minLevel = calculateValueOfLevel(value, max, true);
64
+
65
+ const minAbsPeakBase = 0.005 * max;
66
+ const minAllowed = 3 * xMaxAbsoluteValue([positive, negative]);
67
+
68
+ const minLevel = Math.max(minAbsPeakBase, minAllowed);
69
+ const minContourLevel = calculateValueOfLevel(minLevel, max, true);
66
70
 
67
71
  const defaultLevel: ContourOptions = {
68
72
  negative: {
69
73
  numberOfLayers: 10,
70
- contourLevels: [minLevel, 100],
74
+ contourLevels: [minContourLevel, 100],
71
75
  },
72
76
  positive: {
73
77
  numberOfLayers: 10,
74
- contourLevels: [minLevel, 100],
78
+ contourLevels: [minContourLevel, 100],
75
79
  },
76
80
  };
77
81
  return defaultLevel;
@@ -21,29 +21,19 @@ interface InitiateDatum2DOptions {
21
21
  colors?: SpectrumTwoDimensionsColor[];
22
22
  }
23
23
 
24
- export function initiateDatum2D(
25
- spectrum: any,
26
- options: InitiateDatum2DOptions = {},
27
- ): Spectrum2D {
28
- const { usedColors, colors } = options;
29
- const datum: any = { ...spectrum };
30
-
31
- datum.id = spectrum.id || crypto.randomUUID();
32
-
33
- datum.display = {
24
+ function initiateDisplay(spectrum: any, options: InitiateDatum2DOptions) {
25
+ return {
34
26
  isPositiveVisible: true,
35
27
  isNegativeVisible: true,
36
28
  isVisible: true,
37
- contourOptions:
38
- 'rr' in spectrum.data
39
- ? getDefaultContoursLevel(spectrum)
40
- : DEFAULT_CONTOURS_OPTIONS,
41
29
  dimension: 2,
42
30
  ...spectrum.display,
43
- ...get2DColor(spectrum, { usedColors, colors }),
31
+ ...get2DColor(spectrum, options),
44
32
  };
33
+ }
45
34
 
46
- datum.info = {
35
+ function initiateInfo(spectrum: any) {
36
+ return {
47
37
  nucleus: ['1H', '1H'],
48
38
  isFt: true,
49
39
  isFid: false,
@@ -51,6 +41,32 @@ export function initiateDatum2D(
51
41
  dimension: 2,
52
42
  ...spectrum.info,
53
43
  };
44
+ }
45
+ function initiateContoursLevels(spectrum: any) {
46
+ const {
47
+ display: { contourOptions },
48
+ data,
49
+ } = spectrum;
50
+
51
+ if (contourOptions) return contourOptions;
52
+
53
+ if ('rr' in data) return getDefaultContoursLevel(spectrum);
54
+
55
+ return DEFAULT_CONTOURS_OPTIONS;
56
+ }
57
+
58
+ export function initiateDatum2D(
59
+ spectrum: any,
60
+ options: InitiateDatum2DOptions = {},
61
+ ): Spectrum2D {
62
+ const { usedColors, colors } = options;
63
+ const datum: any = { ...spectrum };
64
+
65
+ datum.id = spectrum.id || crypto.randomUUID();
66
+
67
+ datum.display = initiateDisplay(spectrum, { usedColors, colors });
68
+
69
+ datum.info = initiateInfo(spectrum);
54
70
 
55
71
  datum.originalInfo = datum.info;
56
72
 
@@ -67,6 +83,8 @@ export function initiateDatum2D(
67
83
  //reapply filters after load the original data
68
84
  Filters2DManager.reapplyFilters(datum);
69
85
 
86
+ datum.display.contourOptions = initiateContoursLevels(datum);
87
+
70
88
  return datum;
71
89
  }
72
90
 
@@ -1 +1 @@
1
- export default { version: 'v0.63.1' };
1
+ export default { version: 'v0.64.0' };