nmrium 0.31.0 → 0.33.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 (178) hide show
  1. package/lib/component/1d/Chart1D.js +1 -1
  2. package/lib/component/1d/FooterBanner.js +17 -10
  3. package/lib/component/1d/{Integral.d.ts → integral/Integral.d.ts} +0 -0
  4. package/lib/component/1d/{Integral.js → integral/Integral.js} +2 -2
  5. package/lib/component/1d/integral/IntegralIndicator.d.ts +9 -0
  6. package/lib/component/1d/integral/IntegralIndicator.js +27 -0
  7. package/lib/component/1d/{IntegralResizable.d.ts → integral/IntegralResizable.d.ts} +0 -0
  8. package/lib/component/1d/integral/IntegralResizable.js +69 -0
  9. package/lib/component/1d/{IntegralsSeries.d.ts → integral/IntegralsSeries.d.ts} +0 -0
  10. package/lib/component/1d/{IntegralsSeries.js → integral/IntegralsSeries.js} +3 -3
  11. package/lib/component/1d/ranges/Range.js +27 -50
  12. package/lib/component/1d/utilities/scale.js +2 -2
  13. package/lib/component/2d/Contours.js +61 -42
  14. package/lib/component/2d/Left1DChart.js +1 -1
  15. package/lib/component/2d/Top1DChart.js +1 -1
  16. package/lib/component/EventsTrackers/BrushTracker.js +30 -21
  17. package/lib/component/NMRium.d.ts +1 -1
  18. package/lib/component/NMRium.js +1 -1
  19. package/lib/component/SplitPaneWrapper.js +1 -1
  20. package/lib/component/elements/EditableColumn.d.ts +3 -1
  21. package/lib/component/elements/EditableColumn.js +18 -3
  22. package/lib/component/elements/formik/FormikColorPicker.d.ts +0 -1
  23. package/lib/component/elements/formik/FormikColorPicker.js +5 -8
  24. package/lib/component/elements/formik/FormikInput.d.ts +0 -1
  25. package/lib/component/elements/formik/FormikInput.js +8 -19
  26. package/lib/component/elements/formik/FormikOnChange.d.ts +1 -1
  27. package/lib/component/elements/formik/FormikOnChange.js +13 -10
  28. package/lib/component/elements/formik/FormikSlider.d.ts +2 -4
  29. package/lib/component/elements/formik/FormikSlider.js +8 -11
  30. package/lib/component/hooks/useActiveSpectrumStyleOptions.js +1 -1
  31. package/lib/component/hooks/useExport.js +1 -1
  32. package/lib/component/loader/DropZone.js +9 -1
  33. package/lib/component/modal/ExportAsMatrixModal.js +1 -1
  34. package/lib/component/modal/editRange/forms/components/SignalFormInfo.js +1 -1
  35. package/lib/component/modal/setting/GeneralTabContent.js +1 -1
  36. package/lib/component/panels/MoleculesPanel/MoleculeHeader.js +1 -1
  37. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +1 -1
  38. package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -1
  39. package/lib/component/panels/PeaksPanel/PeaksTable.js +1 -1
  40. package/lib/component/panels/RangesPanel/RangesHeader.js +1 -1
  41. package/lib/component/panels/RangesPanel/RangesPanel.js +1 -1
  42. package/lib/component/panels/RangesPanel/RangesTableRow.js +1 -3
  43. package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.js +1 -1
  44. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.d.ts +1 -1
  45. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.js +2 -1
  46. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.d.ts +1 -1
  47. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.js +2 -1
  48. package/lib/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +3 -26
  49. package/lib/component/panels/extra/preferences/ColumnsHelper.js +5 -2
  50. package/lib/component/reducer/Reducer.d.ts +20 -59
  51. package/lib/component/reducer/Reducer.js +24 -10
  52. package/lib/component/reducer/actions/DomainActions.js +3 -2
  53. package/lib/component/reducer/actions/FiltersActions.js +12 -3
  54. package/lib/component/reducer/actions/IntegralsActions.js +6 -5
  55. package/lib/component/reducer/actions/PeaksActions.js +7 -6
  56. package/lib/component/reducer/actions/PreferencesActions.js +18 -36
  57. package/lib/component/reducer/actions/RangesActions.d.ts +1 -1
  58. package/lib/component/reducer/actions/RangesActions.js +20 -16
  59. package/lib/component/reducer/actions/SpectrumsActions.js +13 -6
  60. package/lib/component/reducer/actions/ToolsActions.d.ts +1 -1
  61. package/lib/component/reducer/actions/ToolsActions.js +15 -28
  62. package/lib/component/reducer/actions/ZonesActions.js +9 -8
  63. package/lib/component/reducer/core/Constants.js +1 -1
  64. package/lib/component/reducer/helper/getActiveSpectrum.d.ts +3 -0
  65. package/lib/component/reducer/helper/getActiveSpectrum.js +4 -0
  66. package/lib/component/reducer/preferences/preferencesReducer.d.ts +2 -2
  67. package/lib/component/toolbar/BasicToolBar.js +8 -7
  68. package/lib/component/utility/FileUtility.d.ts +1 -8
  69. package/lib/component/utility/FileUtility.js +2 -17
  70. package/lib/component/utility/{Export.d.ts → export.d.ts} +0 -0
  71. package/lib/component/utility/{Export.js → export.js} +27 -44
  72. package/lib/component/utility/formatNumber.d.ts +6 -1
  73. package/lib/component/utility/formatNumber.js +4 -3
  74. package/lib/component/workspaces/Workspace.d.ts +1 -1
  75. package/lib/component/workspaces/exercise.js +4 -4
  76. package/lib/component/workspaces/workspaceDefaultProperties.js +1 -1
  77. package/lib/data/Filters.d.ts +1 -2
  78. package/lib/data/Filters.js +1 -2
  79. package/lib/data/SpectraManager.d.ts +1 -2
  80. package/lib/data/SpectraManager.js +22 -55
  81. package/lib/data/data1d/filter1d/fft.js +21 -4
  82. package/lib/data/data1d/filter1d/phaseCorrection.js +11 -5
  83. package/lib/data/data2d/Processing2D.js +3 -2
  84. package/lib/data/data2d/Spectrum2D/contours.d.ts +40 -0
  85. package/lib/data/data2d/Spectrum2D/contours.js +132 -0
  86. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +2 -3
  87. package/lib/data/types/common/Source.d.ts +1 -0
  88. package/lib/data/types/data2d/Data2D.d.ts +2 -0
  89. package/lib/data/types/data2d/Datum2D.d.ts +0 -1
  90. package/lib/data/utilities/calculateSanPlot.d.ts +8 -0
  91. package/lib/data/utilities/calculateSanPlot.js +31 -0
  92. package/lib/types/NMRiumGeneralPreferences.d.ts +2 -2
  93. package/lib/versionInfo.js +1 -1
  94. package/lib-cjs/component/1d/Chart1D.js +1 -1
  95. package/lib-cjs/component/1d/FooterBanner.js +16 -9
  96. package/lib-cjs/component/1d/{Integral.js → integral/Integral.js} +2 -2
  97. package/lib-cjs/component/1d/integral/IntegralIndicator.js +31 -0
  98. package/lib-cjs/component/1d/integral/IntegralResizable.js +74 -0
  99. package/lib-cjs/component/1d/{IntegralsSeries.js → integral/IntegralsSeries.js} +3 -3
  100. package/lib-cjs/component/1d/ranges/Range.js +27 -50
  101. package/lib-cjs/component/1d/utilities/scale.js +2 -2
  102. package/lib-cjs/component/2d/Contours.js +60 -41
  103. package/lib-cjs/component/2d/Left1DChart.js +1 -1
  104. package/lib-cjs/component/2d/Top1DChart.js +1 -1
  105. package/lib-cjs/component/EventsTrackers/BrushTracker.js +30 -21
  106. package/lib-cjs/component/NMRium.js +2 -2
  107. package/lib-cjs/component/SplitPaneWrapper.js +1 -1
  108. package/lib-cjs/component/elements/EditableColumn.js +18 -3
  109. package/lib-cjs/component/elements/formik/FormikColorPicker.js +4 -7
  110. package/lib-cjs/component/elements/formik/FormikInput.js +8 -19
  111. package/lib-cjs/component/elements/formik/FormikOnChange.js +13 -10
  112. package/lib-cjs/component/elements/formik/FormikSlider.js +7 -10
  113. package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +1 -1
  114. package/lib-cjs/component/hooks/useExport.js +6 -6
  115. package/lib-cjs/component/loader/DropZone.js +9 -1
  116. package/lib-cjs/component/modal/ExportAsMatrixModal.js +2 -2
  117. package/lib-cjs/component/modal/editRange/forms/components/SignalFormInfo.js +1 -1
  118. package/lib-cjs/component/modal/setting/GeneralTabContent.js +1 -1
  119. package/lib-cjs/component/panels/MoleculesPanel/MoleculeHeader.js +1 -1
  120. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +4 -4
  121. package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +2 -2
  122. package/lib-cjs/component/panels/PeaksPanel/PeaksTable.js +1 -1
  123. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +2 -2
  124. package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +2 -2
  125. package/lib-cjs/component/panels/RangesPanel/RangesTableRow.js +1 -3
  126. package/lib-cjs/component/panels/SpectrumsPanel/SpectrumsTabs.js +2 -2
  127. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.js +2 -1
  128. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.js +2 -1
  129. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -25
  130. package/lib-cjs/component/panels/extra/preferences/ColumnsHelper.js +5 -2
  131. package/lib-cjs/component/reducer/Reducer.js +23 -9
  132. package/lib-cjs/component/reducer/actions/DomainActions.js +3 -2
  133. package/lib-cjs/component/reducer/actions/FiltersActions.js +12 -3
  134. package/lib-cjs/component/reducer/actions/IntegralsActions.js +6 -5
  135. package/lib-cjs/component/reducer/actions/PeaksActions.js +7 -6
  136. package/lib-cjs/component/reducer/actions/PreferencesActions.js +18 -36
  137. package/lib-cjs/component/reducer/actions/RangesActions.js +20 -16
  138. package/lib-cjs/component/reducer/actions/SpectrumsActions.js +12 -5
  139. package/lib-cjs/component/reducer/actions/ToolsActions.js +15 -28
  140. package/lib-cjs/component/reducer/actions/ZonesActions.js +9 -8
  141. package/lib-cjs/component/reducer/core/Constants.js +1 -1
  142. package/lib-cjs/component/reducer/helper/getActiveSpectrum.js +8 -0
  143. package/lib-cjs/component/toolbar/BasicToolBar.js +7 -6
  144. package/lib-cjs/component/utility/FileUtility.js +2 -18
  145. package/lib-cjs/component/utility/{Export.js → export.js} +51 -45
  146. package/lib-cjs/component/utility/formatNumber.js +4 -3
  147. package/lib-cjs/component/workspaces/exercise.js +4 -4
  148. package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +1 -1
  149. package/lib-cjs/data/Filters.js +1 -3
  150. package/lib-cjs/data/SpectraManager.js +23 -57
  151. package/lib-cjs/data/data1d/filter1d/fft.js +20 -3
  152. package/lib-cjs/data/data1d/filter1d/phaseCorrection.js +10 -4
  153. package/lib-cjs/data/data2d/Processing2D.js +3 -2
  154. package/lib-cjs/data/data2d/Spectrum2D/contours.js +138 -0
  155. package/lib-cjs/data/data2d/Spectrum2D/initiateDatum2D.js +2 -3
  156. package/lib-cjs/data/utilities/calculateSanPlot.js +35 -0
  157. package/lib-cjs/versionInfo.js +1 -1
  158. package/package.json +21 -20
  159. package/lib/component/1d/IntegralResizable.js +0 -72
  160. package/lib/component/panels/RangesPanel/TableColumns/format.d.ts +0 -1
  161. package/lib/component/panels/RangesPanel/TableColumns/format.js +0 -8
  162. package/lib/data/data1d/Data1DManager.d.ts +0 -3
  163. package/lib/data/data1d/Data1DManager.js +0 -98
  164. package/lib/data/data1d/filter1d/absolute.d.ts +0 -13
  165. package/lib/data/data1d/filter1d/absolute.js +0 -26
  166. package/lib/data/data2d/Data2DManager.d.ts +0 -3
  167. package/lib/data/data2d/Data2DManager.js +0 -34
  168. package/lib/data/types/data2d/Contour.d.ts +0 -4
  169. package/lib/data/types/data2d/Contour.js +0 -1
  170. package/lib/data/types/data2d/Contours.d.ts +0 -2
  171. package/lib/data/types/data2d/Contours.js +0 -1
  172. package/lib-cjs/component/1d/IntegralResizable.js +0 -77
  173. package/lib-cjs/component/panels/RangesPanel/TableColumns/format.js +0 -14
  174. package/lib-cjs/data/data1d/Data1DManager.js +0 -104
  175. package/lib-cjs/data/data1d/filter1d/absolute.js +0 -32
  176. package/lib-cjs/data/data2d/Data2DManager.js +0 -40
  177. package/lib-cjs/data/types/data2d/Contour.js +0 -2
  178. package/lib-cjs/data/types/data2d/Contours.js +0 -2
@@ -1,9 +1,8 @@
1
- /// <reference types="node" />
2
1
  import { CorrelationData } from 'nmr-correlation';
3
2
  import { SpectraAnalysis } from '../../data/data1d/MultipleAnalysis';
4
3
  import { ApodizationOptions } from '../../data/data1d/filter1d/apodization';
4
+ import { ContoursLevels } from '../../data/data2d/Spectrum2D/contours';
5
5
  import { FloatingMolecules, StateMoleculeExtended } from '../../data/molecules/Molecule';
6
- import { Contours } from '../../data/types/data2d/Contours';
7
6
  import { UsedColors } from '../../types/UsedColors';
8
7
  import { Spectra } from '../NMRium';
9
8
  import { DISPLAYER_MODE } from './core/Constants';
@@ -69,6 +68,9 @@ export interface ViewState {
69
68
  */
70
69
  activeTab: string;
71
70
  };
71
+ zoom: {
72
+ levels: ContoursLevels;
73
+ };
72
74
  }
73
75
  export declare const rangeStateInit: {
74
76
  showMultiplicityTrees: boolean;
@@ -103,10 +105,6 @@ export interface State {
103
105
  * spectra list (1d and 2d)
104
106
  */
105
107
  data: Spectra;
106
- /**
107
- * calculated contours for 2d spectra
108
- */
109
- contours: Contours;
110
108
  /**
111
109
  * snapshot of the spectra data once phase correction activated
112
110
  *
@@ -307,31 +305,10 @@ export declare const spectrumReducer: (base: {
307
305
  readonly data: readonly ({
308
306
  readonly id: string;
309
307
  readonly source: {
308
+ readonly jcamp: string;
310
309
  readonly jcampURL: string;
311
310
  readonly jcampSpectrumIndex: number;
312
- readonly file: {
313
- readonly lastModified: number;
314
- readonly name: string;
315
- readonly webkitRelativePath: string;
316
- readonly size: number;
317
- readonly type: string;
318
- readonly arrayBuffer: {
319
- (): Promise<ArrayBuffer>;
320
- (): Promise<ArrayBuffer>;
321
- };
322
- readonly slice: {
323
- (start?: number | undefined, end?: number | undefined, contentType?: string | undefined): Blob;
324
- (start?: number | undefined, end?: number | undefined, contentType?: string | undefined): Blob;
325
- };
326
- readonly stream: {
327
- (): ReadableStream<Uint8Array>;
328
- (): NodeJS.ReadableStream;
329
- };
330
- readonly text: {
331
- (): Promise<string>;
332
- (): Promise<string>;
333
- };
334
- };
311
+ readonly file: File;
335
312
  };
336
313
  readonly display: {
337
314
  readonly name: string;
@@ -807,31 +784,10 @@ export declare const spectrumReducer: (base: {
807
784
  } | {
808
785
  readonly id: string;
809
786
  readonly source: {
787
+ readonly jcamp: string;
810
788
  readonly jcampURL: string;
811
789
  readonly jcampSpectrumIndex: number;
812
- readonly file: {
813
- readonly lastModified: number;
814
- readonly name: string;
815
- readonly webkitRelativePath: string;
816
- readonly size: number;
817
- readonly type: string;
818
- readonly arrayBuffer: {
819
- (): Promise<ArrayBuffer>;
820
- (): Promise<ArrayBuffer>;
821
- };
822
- readonly slice: {
823
- (start?: number | undefined, end?: number | undefined, contentType?: string | undefined): Blob;
824
- (start?: number | undefined, end?: number | undefined, contentType?: string | undefined): Blob;
825
- };
826
- readonly stream: {
827
- (): ReadableStream<Uint8Array>;
828
- (): NodeJS.ReadableStream;
829
- };
830
- readonly text: {
831
- (): Promise<string>;
832
- (): Promise<string>;
833
- };
834
- };
790
+ readonly file: File;
835
791
  };
836
792
  readonly display: {
837
793
  readonly name: string;
@@ -872,15 +828,19 @@ export declare const spectrumReducer: (base: {
872
828
  readonly z: readonly (readonly number[])[];
873
829
  readonly minX: number;
874
830
  readonly minY: number;
831
+ readonly minZ: number;
875
832
  readonly maxX: number;
876
833
  readonly maxY: number;
834
+ readonly maxZ: number;
877
835
  };
878
836
  readonly originalData?: {
879
837
  readonly z: readonly (readonly number[])[];
880
838
  readonly minX: number;
881
839
  readonly minY: number;
840
+ readonly minZ: number;
882
841
  readonly maxX: number;
883
842
  readonly maxY: number;
843
+ readonly maxZ: number;
884
844
  } | undefined;
885
845
  readonly zones: {
886
846
  readonly values: readonly {
@@ -947,14 +907,7 @@ export declare const spectrumReducer: (base: {
947
907
  readonly flag: boolean;
948
908
  readonly value: any;
949
909
  }[];
950
- readonly processingController: any;
951
910
  })[];
952
- readonly contours: {
953
- readonly [x: string]: {
954
- readonly negative: readonly (readonly number[])[];
955
- readonly positive: readonly (readonly number[])[];
956
- };
957
- };
958
911
  readonly tempData: any;
959
912
  readonly xDomain: readonly number[];
960
913
  readonly yDomain: readonly number[];
@@ -1029,6 +982,14 @@ export declare const spectrumReducer: (base: {
1029
982
  };
1030
983
  readonly activeTab: string;
1031
984
  };
985
+ readonly zoom: {
986
+ readonly levels: {
987
+ readonly [x: string]: {
988
+ readonly positive: number;
989
+ readonly negative: number;
990
+ };
991
+ };
992
+ };
1032
993
  };
1033
994
  readonly verticalAlign: {
1034
995
  readonly align: VerticalAlignment;
@@ -1,9 +1,10 @@
1
1
  import { v4 } from '@lukeed/uuid';
2
2
  import { produce } from 'immer';
3
3
  import { buildCorrelationData } from 'nmr-correlation';
4
- import { read as readDropFiles, migrate } from 'nmr-load-save';
4
+ import { read as readDropFiles, readNMRiumObject } from 'nmr-load-save';
5
5
  import { predictSpectra } from '../../data/PredictionManager';
6
- import * as SpectraManager from '../../data/SpectraManager';
6
+ import { initiateDatum1D } from '../../data/data1d/Spectrum1D';
7
+ import { initiateDatum2D } from '../../data/data2d/Spectrum2D';
7
8
  import { useChartData } from '../context/ChartContext';
8
9
  import { DefaultTolerance } from '../panels/SummaryPanel/CorrelationTable/Constants';
9
10
  import { options } from '../toolbar/ToolTypes';
@@ -41,7 +42,6 @@ export const zoneStateInit = {
41
42
  export const getInitialState = () => ({
42
43
  actionType: '',
43
44
  data: [],
44
- contours: {},
45
45
  tempData: null,
46
46
  xDomain: [],
47
47
  yDomain: [],
@@ -60,7 +60,7 @@ export const getInitialState = () => ({
60
60
  margin: {
61
61
  top: 10,
62
62
  right: 20,
63
- bottom: 70,
63
+ bottom: 50,
64
64
  left: 0,
65
65
  },
66
66
  mode: 'RTL',
@@ -70,6 +70,9 @@ export const getInitialState = () => ({
70
70
  ranges: [],
71
71
  zones: [],
72
72
  spectra: { activeSpectra: {}, activeTab: '' },
73
+ zoom: {
74
+ levels: {},
75
+ },
73
76
  },
74
77
  verticalAlign: {
75
78
  align: 'bottom',
@@ -131,23 +134,34 @@ export function initState(state) {
131
134
  };
132
135
  }
133
136
  export function dispatchMiddleware(dispatch) {
134
- const usedColors = { '1d': [], '2d': [] };
137
+ let usedColors = { '1d': [], '2d': [] };
135
138
  return (action) => {
136
139
  switch (action.type) {
137
140
  case types.INITIATE: {
138
141
  if (action.payload) {
139
- const { spectra, ...res } = migrate(action.payload);
140
- void SpectraManager.fromJSON(spectra, usedColors).then((data) => {
141
- action.payload = { spectra: data, ...res, usedColors };
142
+ usedColors = { '1d': [], '2d': [] };
143
+ void readNMRiumObject(action.payload).then((data) => {
144
+ const { spectra: spectraIn } = data;
145
+ const spectra = [];
146
+ for (let spectrum of spectraIn) {
147
+ const { info } = spectrum;
148
+ if (info.dimension === 1) {
149
+ spectra.push(initiateDatum1D(spectrum, usedColors));
150
+ }
151
+ else if (info.dimension === 2) {
152
+ spectra.push(initiateDatum2D(spectrum, usedColors));
153
+ }
154
+ }
155
+ action.payload = { ...data, usedColors, spectra };
142
156
  dispatch(action);
143
157
  });
144
158
  }
145
159
  break;
146
160
  }
147
161
  case types.LOAD_DROP_FILES: {
148
- const { files } = action;
162
+ const { fileCollection } = action;
149
163
  action.usedColors = usedColors;
150
- readDropFiles(files, usedColors)
164
+ readDropFiles(fileCollection)
151
165
  .then((data) => {
152
166
  action.data = data;
153
167
  dispatch(action);
@@ -3,12 +3,13 @@ import { get1DDataXY } from '../../../data/data1d/Spectrum1D/get1DDataXY';
3
3
  import { isSpectrum2D } from '../../../data/data2d/Spectrum2D';
4
4
  import nucleusToString from '../../utility/nucleusToString';
5
5
  import { DISPLAYER_MODE } from '../core/Constants';
6
+ import { getActiveSpectrum } from '../helper/getActiveSpectrum';
6
7
  function getActiveData(draft) {
7
8
  let data = draft.data.filter((datum) => nucleusToString(datum.info.nucleus) === draft.view.spectra.activeTab &&
8
9
  datum.info.dimension === 1);
9
10
  // todo: refactor this
10
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
11
- if (activeSpectrum) {
11
+ const activeSpectrum = getActiveSpectrum(draft);
12
+ if (activeSpectrum?.id) {
12
13
  const activeSpectrumIndex = data.findIndex((datum) => datum.id === activeSpectrum?.id);
13
14
  if (activeSpectrumIndex !== -1) {
14
15
  const isFid = data[activeSpectrumIndex].info.isFid || false;
@@ -102,7 +102,10 @@ function applyManualPhaseCorrectionFilter(draft, filterOptions) {
102
102
  const { index } = activeSpectrum;
103
103
  const { ph0, ph1 } = filterOptions;
104
104
  FiltersManager.applyFilter(draft.data[index], [
105
- { name: Filters.phaseCorrection.id, options: { ph0, ph1 } },
105
+ {
106
+ name: Filters.phaseCorrection.id,
107
+ options: { ph0, ph1, absolute: false },
108
+ },
106
109
  ]);
107
110
  resetSelectedTool(draft);
108
111
  draft.tempData = null;
@@ -112,7 +115,10 @@ function applyAbsoluteFilter(draft) {
112
115
  const activeSpectrum = getActiveSpectrumOrFail(draft);
113
116
  const { index } = activeSpectrum;
114
117
  FiltersManager.applyFilter(draft.data[index], [
115
- { name: Filters.absolute.id, options: {} },
118
+ {
119
+ name: Filters.phaseCorrection.id,
120
+ options: { absolute: true, ph0: 0, ph1: 0 },
121
+ },
116
122
  ]);
117
123
  resetSelectedTool(draft);
118
124
  draft.tempData = null;
@@ -123,7 +129,10 @@ function applyAutoPhaseCorrectionFilter(draft) {
123
129
  const { index } = activeSpectrum;
124
130
  const { ph0, ph1 } = autoPhaseCorrection(draft.data[index]);
125
131
  FiltersManager.applyFilter(draft.data[index], [
126
- { name: Filters.phaseCorrection.id, options: { ph0, ph1 } },
132
+ {
133
+ name: Filters.phaseCorrection.id,
134
+ options: { ph0, ph1, absolute: false },
135
+ },
127
136
  ]);
128
137
  resetSelectedTool(draft);
129
138
  draft.tempData = null;
@@ -3,11 +3,12 @@ import { original } from 'immer';
3
3
  import { xyIntegration } from 'ml-spectra-processing';
4
4
  import { updateIntegralsRelativeValues, changeIntegralsRelative, getShiftX, } from '../../../data/data1d/Spectrum1D';
5
5
  import { initSumOptions, setSumOptions, } from '../../../data/data1d/Spectrum1D/SumManager';
6
+ import { getActiveSpectrum } from '../helper/getActiveSpectrum';
6
7
  import getRange from '../helper/getRange';
7
8
  import { setIntegralsYDomain } from './DomainActions';
8
9
  function handleChangeIntegralSum(draft, options) {
9
10
  const { data, view: { spectra: { activeTab: nucleus }, }, } = draft;
10
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
11
+ const activeSpectrum = getActiveSpectrum(draft);
11
12
  if (activeSpectrum?.id) {
12
13
  const { index } = activeSpectrum;
13
14
  const datum = data[index];
@@ -18,7 +19,7 @@ function handleChangeIntegralSum(draft, options) {
18
19
  function addIntegral(draft, action) {
19
20
  const { startX, endX } = action;
20
21
  const { data, molecules, view: { spectra: { activeTab: nucleus }, }, } = draft;
21
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
22
+ const activeSpectrum = getActiveSpectrum(draft);
22
23
  const [from, to] = getRange(draft, { startX, endX });
23
24
  if (activeSpectrum?.id) {
24
25
  const datum = data[activeSpectrum.index];
@@ -43,7 +44,7 @@ function addIntegral(draft, action) {
43
44
  }
44
45
  }
45
46
  function deleteIntegral(draft, action) {
46
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
47
+ const activeSpectrum = getActiveSpectrum(draft);
47
48
  if (activeSpectrum) {
48
49
  const state = original(draft);
49
50
  const { index } = activeSpectrum;
@@ -60,7 +61,7 @@ function deleteIntegral(draft, action) {
60
61
  }
61
62
  }
62
63
  function changeIntegral(draft, action) {
63
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
64
+ const activeSpectrum = getActiveSpectrum(draft);
64
65
  const state = original(draft);
65
66
  const integral = action.payload.data;
66
67
  if (activeSpectrum?.id) {
@@ -81,7 +82,7 @@ function changeIntegral(draft, action) {
81
82
  }
82
83
  }
83
84
  function handleChangeIntegralsRelativeValue(draft, action) {
84
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
85
+ const activeSpectrum = getActiveSpectrum(draft);
85
86
  const data = action.payload.data;
86
87
  if (activeSpectrum?.id) {
87
88
  const { index } = activeSpectrum;
@@ -3,9 +3,10 @@ import { original } from 'immer';
3
3
  import { xFindClosestIndex } from 'ml-spectra-processing';
4
4
  import { getShiftX, lookupPeak, autoPeakPicking, optimizePeaks, } from '../../../data/data1d/Spectrum1D';
5
5
  import { options } from '../../toolbar/ToolTypes';
6
+ import { getActiveSpectrum } from '../helper/getActiveSpectrum';
6
7
  import getRange from '../helper/getRange';
7
8
  function addPeak(draft, mouseCoordinates) {
8
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
9
+ const activeSpectrum = getActiveSpectrum(draft);
9
10
  const state = original(draft);
10
11
  if (activeSpectrum?.id && state) {
11
12
  const { index } = activeSpectrum;
@@ -32,7 +33,7 @@ function addPeak(draft, mouseCoordinates) {
32
33
  }
33
34
  function addPeaks(draft, action) {
34
35
  const state = original(draft);
35
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
36
+ const activeSpectrum = getActiveSpectrum(draft);
36
37
  if (activeSpectrum) {
37
38
  const { index } = activeSpectrum;
38
39
  const datumOriginal = state.data[index];
@@ -55,7 +56,7 @@ function addPeaks(draft, action) {
55
56
  }
56
57
  }
57
58
  function deletePeak(draft, peakData) {
58
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
59
+ const activeSpectrum = getActiveSpectrum(draft);
59
60
  if (activeSpectrum) {
60
61
  const { index } = activeSpectrum;
61
62
  const state = original(draft);
@@ -70,7 +71,7 @@ function deletePeak(draft, peakData) {
70
71
  }
71
72
  function handleOptimizePeaks(draft, action) {
72
73
  const { peaks } = action.payload;
73
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
74
+ const activeSpectrum = getActiveSpectrum(draft);
74
75
  if (activeSpectrum?.id) {
75
76
  const { index } = activeSpectrum;
76
77
  const datum = draft.data[index];
@@ -84,7 +85,7 @@ function handleOptimizePeaks(draft, action) {
84
85
  }
85
86
  }
86
87
  function handleAutoPeakPicking(draft, autOptions) {
87
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
88
+ const activeSpectrum = getActiveSpectrum(draft);
88
89
  if (activeSpectrum?.id) {
89
90
  draft.toolOptions.selectedTool = options.zoom.id;
90
91
  draft.toolOptions.selectedOptionPanel = null;
@@ -103,7 +104,7 @@ function handleAutoPeakPicking(draft, autOptions) {
103
104
  }
104
105
  function changePeakShapeHandler(draft, action) {
105
106
  const { shape, id } = action.payload;
106
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
107
+ const activeSpectrum = getActiveSpectrum(draft);
107
108
  if (activeSpectrum?.id) {
108
109
  const { index } = activeSpectrum;
109
110
  const datum = draft.data[index];
@@ -1,7 +1,7 @@
1
- import cloneDeep from 'lodash/cloneDeep';
2
1
  import groupByInfoKey from '../../utility/GroupByInfoKey';
3
2
  import nucleusToString from '../../utility/nucleusToString';
4
3
  import { DEFAULT_YAXIS_SHIFT_VALUE, DISPLAYER_MODE } from '../core/Constants';
4
+ import { getActiveSpectrum } from '../helper/getActiveSpectrum';
5
5
  import { setDomain } from './DomainActions';
6
6
  function changeSpectrumVerticalAlignment(draft, options) {
7
7
  function stack(spectra = []) {
@@ -54,16 +54,12 @@ function changeSpectrumVerticalAlignment(draft, options) {
54
54
  }
55
55
  function setKeyPreferencesHandler(draft, keyCode) {
56
56
  const { data, zoom, xDomain, xDomains, yDomain, yDomains, originDomain, margin, displayerMode, view, } = draft;
57
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
58
- if (view.spectra.activeTab) {
57
+ const { spectra: { activeTab }, } = view;
58
+ const activeSpectrum = getActiveSpectrum(draft);
59
+ if (activeTab) {
59
60
  const groupByNucleus = groupByInfoKey('nucleus');
60
61
  const spectrumsGroupsList = groupByNucleus(data);
61
- const level = displayerMode === DISPLAYER_MODE.DM_2D
62
- ? spectrumsGroupsList[view.spectra.activeTab].reduce((acc, datum) => {
63
- acc[datum.id] = datum.processingController.getLevel();
64
- return acc;
65
- }, {})
66
- : null;
62
+ const spectra = spectrumsGroupsList[activeTab];
67
63
  draft.keysPreferences[keyCode] = {
68
64
  activeSpectrum,
69
65
  displayerMode,
@@ -74,29 +70,25 @@ function setKeyPreferencesHandler(draft, keyCode) {
74
70
  yDomain,
75
71
  yDomains,
76
72
  originDomain,
77
- level,
78
73
  margin,
79
- data: spectrumsGroupsList[view.spectra.activeTab].reduce((acc, datum) => {
80
- acc[datum.id] = {
81
- display: {
82
- color: datum.display.color,
83
- isVisible: datum.display.isVisible,
84
- isPeaksMarkersVisible: datum.display.isPeaksMarkersVisible,
85
- },
86
- };
87
- return acc;
88
- }, {}),
74
+ data: spectra,
89
75
  };
90
76
  }
91
77
  }
78
+ function setSpectraDisplayPreferences(draft, preferences) {
79
+ draft.data.forEach((datum, index) => {
80
+ if (nucleusToString(datum.info.nucleus) === preferences.activeTab) {
81
+ draft.data[index].display = {
82
+ ...datum.display,
83
+ ...preferences.data[datum.id].display,
84
+ };
85
+ }
86
+ });
87
+ }
92
88
  function applyKeyPreferencesHandler(draft, keyCode) {
93
89
  const preferences = draft.keysPreferences[keyCode];
94
90
  if (preferences) {
95
- draft.data.forEach((datum, index) => {
96
- if (nucleusToString(datum.info.nucleus) === preferences.activeTab) {
97
- draft.data[index].display = Object.assign(cloneDeep(datum.display), preferences.data[datum.id].display);
98
- }
99
- });
91
+ setSpectraDisplayPreferences(draft, preferences);
100
92
  draft.view = preferences.view;
101
93
  draft.displayerMode = preferences.displayerMode;
102
94
  draft.margin = preferences.margin;
@@ -106,17 +98,7 @@ function applyKeyPreferencesHandler(draft, keyCode) {
106
98
  draft.yDomain = preferences.yDomain;
107
99
  draft.originDomain = preferences.originDomain;
108
100
  draft.yDomains = preferences.yDomains;
109
- if (draft.displayerMode === DISPLAYER_MODE.DM_2D) {
110
- for (const datumID of Object.keys(preferences.level)) {
111
- const { levelPositive, levelNegative } = preferences.level[datumID];
112
- const index = draft.data.findIndex((datum) => datum.id === datumID);
113
- const processController = draft.data[index]
114
- .processingController;
115
- processController.setLevel(levelPositive, levelNegative);
116
- draft.contours[datumID] = processController.drawContours();
117
- }
118
- }
119
- else {
101
+ if (draft.displayerMode !== DISPLAYER_MODE.DM_2D) {
120
102
  draft.zoom = preferences.zoom;
121
103
  }
122
104
  }
@@ -13,7 +13,7 @@ declare function handleChangeRangeSum(draft: Draft<State>, options: any): void;
13
13
  declare function handleAddRange(draft: Draft<State>, action: any): void;
14
14
  declare function handleChangeRangeRelativeValue(draft: any, action: any): void;
15
15
  declare function handleChangeRangeSignalValue(draft: any, action: any): void;
16
- declare function handleChangeRangesSumFlag(draft: any, action: any): void;
16
+ declare function handleChangeRangesSumFlag(draft: Draft<State>, action: any): void;
17
17
  declare function handleUpdateRange(draft: Draft<State>, action: any): void;
18
18
  declare function handleShowMultiplicityTrees(draft: Draft<State>, action: any): void;
19
19
  declare function handleShowRangesIntegrals(draft: Draft<State>, action: any): void;
@@ -9,13 +9,14 @@ import { addRange, changeRangeSignal, detectRanges, updateRangesRelativeValues,
9
9
  import { setSumOptions } from '../../../data/data1d/Spectrum1D/SumManager';
10
10
  import { unlink, unlinkInAssignmentData, } from '../../../data/utilities/RangeUtilities';
11
11
  import { rangeStateInit } from '../Reducer';
12
+ import { getActiveSpectrum } from '../helper/getActiveSpectrum';
12
13
  import getRange from '../helper/getRange';
13
14
  import { handleUpdateCorrelations } from './CorrelationsActions';
14
15
  import { setDomain, setIntegralsYDomain } from './DomainActions';
15
16
  import { resetSelectedTool } from './ToolsActions';
16
17
  function handleAutoRangesDetection(draft, options) {
17
18
  const { data, xDomain, molecules, view: { spectra: { activeTab: nucleus }, }, } = draft;
18
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
19
+ const activeSpectrum = getActiveSpectrum(draft);
19
20
  if (activeSpectrum?.id) {
20
21
  const { index, id } = activeSpectrum;
21
22
  const datum = data[index];
@@ -72,7 +73,7 @@ function getRangeIndex(draft, spectrumIndex, rangeID) {
72
73
  return draft.data[spectrumIndex].ranges.values.findIndex((range) => range.id === rangeID);
73
74
  }
74
75
  function handleDeleteRange(draft, action) {
75
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
76
+ const activeSpectrum = getActiveSpectrum(draft);
76
77
  if (activeSpectrum?.id) {
77
78
  const { index } = activeSpectrum;
78
79
  const { data, resetSelectTool = false } = action.payload;
@@ -96,7 +97,7 @@ function handleDeleteRange(draft, action) {
96
97
  }
97
98
  function handleChangeRangeSignalKind(draft, action) {
98
99
  const state = original(draft);
99
- const activeSpectrum = state.view.spectra.activeSpectra[state.view.spectra.activeTab];
100
+ const activeSpectrum = getActiveSpectrum(state);
100
101
  if (activeSpectrum?.id) {
101
102
  const { index } = activeSpectrum;
102
103
  const { rowData, value } = action.payload.data;
@@ -114,7 +115,7 @@ function handleChangeRangeSignalKind(draft, action) {
114
115
  }
115
116
  function handleSaveEditedRange(draft, action) {
116
117
  const state = original(draft);
117
- const activeSpectrum = state.view.spectra.activeSpectra[state.view.spectra.activeTab];
118
+ const activeSpectrum = getActiveSpectrum(state);
118
119
  if (activeSpectrum?.id) {
119
120
  const { index } = activeSpectrum;
120
121
  const { editedRowData, assignmentData } = action.payload;
@@ -157,7 +158,7 @@ function handleDeleteSignal(draft, action) {
157
158
  }
158
159
  }
159
160
  function handleUnlinkRange(draft, action) {
160
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
161
+ const activeSpectrum = getActiveSpectrum(draft);
161
162
  if (activeSpectrum?.id) {
162
163
  const { index } = activeSpectrum;
163
164
  const { assignmentData, rangeData = null, signalIndex = -1, } = action.payload;
@@ -192,7 +193,7 @@ function handleUnlinkRange(draft, action) {
192
193
  }
193
194
  }
194
195
  function handleSetDiaIDRange(draft, action) {
195
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
196
+ const activeSpectrum = getActiveSpectrum(draft);
196
197
  if (activeSpectrum?.id) {
197
198
  const { index } = activeSpectrum;
198
199
  const { rangeData, diaIDs, signalIndex, nbAtoms } = action.payload;
@@ -211,7 +212,7 @@ function handleSetDiaIDRange(draft, action) {
211
212
  }
212
213
  }
213
214
  function handleResizeRange(draft, action) {
214
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
215
+ const activeSpectrum = getActiveSpectrum(draft);
215
216
  if (activeSpectrum?.id) {
216
217
  const { index } = activeSpectrum;
217
218
  changeRange(draft.data[index], action.data);
@@ -219,7 +220,7 @@ function handleResizeRange(draft, action) {
219
220
  }
220
221
  function handleChangeRangeSum(draft, options) {
221
222
  const { data, view: { spectra: { activeTab: nucleus }, }, } = draft;
222
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
223
+ const activeSpectrum = getActiveSpectrum(draft);
223
224
  if (activeSpectrum?.id) {
224
225
  const { index } = activeSpectrum;
225
226
  const datum = data[index];
@@ -231,7 +232,7 @@ function addNewRange(draft, props) {
231
232
  const { startX, endX, id } = props;
232
233
  const range = getRange(draft, { startX, endX });
233
234
  const { view: { spectra: { activeTab: nucleus }, }, molecules, } = draft;
234
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
235
+ const activeSpectrum = getActiveSpectrum(draft);
235
236
  if (activeSpectrum?.id) {
236
237
  const { index } = activeSpectrum;
237
238
  const [from, to] = range;
@@ -268,15 +269,17 @@ function handleAddRange(draft, action) {
268
269
  }
269
270
  function handleChangeRangeRelativeValue(draft, action) {
270
271
  const data = action.payload.data;
271
- if (draft.activeSpectrum?.id) {
272
- const { index } = draft.activeSpectrum;
272
+ const activeSpectrum = getActiveSpectrum(draft);
273
+ if (activeSpectrum?.id) {
274
+ const { index } = activeSpectrum;
273
275
  changeRangeRelativeValue(draft.data[index], data);
274
276
  }
275
277
  }
276
278
  function handleChangeRangeSignalValue(draft, action) {
277
279
  const { rangeID, signalID, value } = action.payload;
278
- if (draft.activeSpectrum?.id) {
279
- const { index } = draft.activeSpectrum;
280
+ const activeSpectrum = getActiveSpectrum(draft);
281
+ if (activeSpectrum?.id) {
282
+ const { index } = activeSpectrum;
280
283
  const shift = changeRangeSignal(draft.data[index], {
281
284
  rangeID,
282
285
  signalID,
@@ -295,14 +298,15 @@ function handleOnChangeRangesData(draft) {
295
298
  }
296
299
  function handleChangeRangesSumFlag(draft, action) {
297
300
  const flag = action.payload;
298
- if (draft.activeSpectrum?.id) {
299
- const { index } = draft.activeSpectrum;
301
+ const activeSpectrum = getActiveSpectrum(draft);
302
+ if (activeSpectrum?.id) {
303
+ const { index } = activeSpectrum;
300
304
  draft.data[index].ranges.options.isSumConstant = !flag;
301
305
  }
302
306
  }
303
307
  function handleUpdateRange(draft, action) {
304
308
  const { range, resetSelectTool = false } = action.payload;
305
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
309
+ const activeSpectrum = getActiveSpectrum(draft);
306
310
  if (activeSpectrum?.id && range.id) {
307
311
  const datum = draft.data[activeSpectrum?.index];
308
312
  const index = datum.ranges.values.findIndex((_range) => _range.id === range.id);
@@ -2,10 +2,12 @@ import { original } from 'immer';
2
2
  import * as Filters from '../../../data/Filters';
3
3
  import { applyFilter } from '../../../data/FiltersManager';
4
4
  import { generateSpectrumFromPublicationString, getReferenceShift, } from '../../../data/data1d/Spectrum1D';
5
- import { getMissingProjection } from '../../../data/data2d/Spectrum2D';
5
+ import { getMissingProjection, isSpectrum2D, } from '../../../data/data2d/Spectrum2D';
6
+ import { contoursManager } from '../../../data/data2d/Spectrum2D/contours';
6
7
  import { options } from '../../toolbar/ToolTypes';
7
8
  import groupByInfoKey from '../../utility/GroupByInfoKey';
8
9
  import { setZoom } from '../helper/Zoom1DManager';
10
+ import { getActiveSpectrum } from '../helper/getActiveSpectrum';
9
11
  import { setDomain, setMode } from './DomainActions';
10
12
  import { resetSpectrumByFilter } from './FiltersActions';
11
13
  import { setTab, setActiveTab } from './ToolsActions';
@@ -65,7 +67,7 @@ function handleChangePeaksMarkersVisibility(draft, data) {
65
67
  }
66
68
  function handleChangeActiveSpectrum(draft, activeSpectrum) {
67
69
  let refreshDomain = false;
68
- const currentActiveSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
70
+ const currentActiveSpectrum = getActiveSpectrum(draft);
69
71
  if (activeSpectrum) {
70
72
  const newIndex = draft.data.findIndex((d) => d.id === activeSpectrum.id);
71
73
  const oldIndex = draft.data.findIndex((d) => d.id === currentActiveSpectrum?.id);
@@ -114,10 +116,15 @@ function handleChangeActiveSpectrum(draft, activeSpectrum) {
114
116
  }
115
117
  }
116
118
  function changeSpectrumSetting(draft, { id, display }) {
117
- const state = original(draft);
118
- const index = state.data.findIndex((d) => d.id === id);
119
+ const index = draft.data.findIndex((d) => d.id === id);
119
120
  if (index !== -1) {
120
- draft.data[index].display = display;
121
+ const spectrum = draft.data[index];
122
+ spectrum.display = display;
123
+ if (isSpectrum2D(spectrum)) {
124
+ const contoursLevels = draft.view.zoom.levels;
125
+ const { checkLevel } = contoursManager(spectrum.id, contoursLevels, spectrum.display.contourOptions);
126
+ contoursLevels[spectrum.id] = checkLevel();
127
+ }
121
128
  }
122
129
  }
123
130
  function handleChangeSpectrumColor(draft, { id, color, key }) {
@@ -144,7 +151,7 @@ function handleDeleteSpectra(draft, action) {
144
151
  function addMissingProjectionHandler(draft, action) {
145
152
  const state = original(draft);
146
153
  const { nucleus } = action;
147
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
154
+ const activeSpectrum = getActiveSpectrum(draft);
148
155
  if (activeSpectrum?.id) {
149
156
  const { index } = activeSpectrum;
150
157
  for (let n of nucleus) {