nmrium 0.30.0 → 0.32.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 (273) hide show
  1. package/lib/component/1d/ApodizationLine.js +3 -1
  2. package/lib/component/1d/FooterBanner.js +20 -11
  3. package/lib/component/1d/IntegralsSeries.js +3 -1
  4. package/lib/component/1d/LinesSeries.js +3 -1
  5. package/lib/component/1d/SpectraTracker.js +1 -1
  6. package/lib/component/1d/Viewer1D.js +3 -1
  7. package/lib/component/1d/jCouplingGraph/JGraph.js +5 -1
  8. package/lib/component/1d/multiAnalysis/MultiAnalysisRanges.js +1 -1
  9. package/lib/component/1d/multiplicityTree/MultiplicityTree.js +3 -1
  10. package/lib/component/1d/peaks/PeakAnnotations.js +3 -1
  11. package/lib/component/1d/peaks/PeaksShapes.js +4 -2
  12. package/lib/component/1d/peaks/usePeakShapesPath.js +7 -3
  13. package/lib/component/1d/ranges/Ranges.js +8 -2
  14. package/lib/component/1d/tool/PeakPointer.js +3 -1
  15. package/lib/component/1d/tool/XLabelPointer.js +3 -1
  16. package/lib/component/2d/Contours.js +4 -2
  17. package/lib/component/2d/FooterBanner.js +3 -1
  18. package/lib/component/2d/Left1DChart.js +1 -1
  19. package/lib/component/2d/Top1DChart.js +1 -1
  20. package/lib/component/2d/Viewer2D.js +4 -4
  21. package/lib/component/2d/XAxis.js +2 -2
  22. package/lib/component/2d/YAxis.js +2 -2
  23. package/lib/component/2d/tools/XYLabelPointer.js +3 -1
  24. package/lib/component/2d/tools/slicing/SlicingView.js +3 -1
  25. package/lib/component/2d/zones/IndicationLines.js +1 -1
  26. package/lib/component/2d/zones/Zones.js +14 -19
  27. package/lib/component/EventsTrackers/BrushTracker.js +30 -21
  28. package/lib/component/NMRium.d.ts +2 -0
  29. package/lib/component/NMRium.js +14 -3
  30. package/lib/component/SplitPaneWrapper.js +1 -1
  31. package/lib/component/elements/EditableColumn.d.ts +3 -1
  32. package/lib/component/elements/EditableColumn.js +18 -3
  33. package/lib/component/elements/popup/Modal/Provider.d.ts +3 -3
  34. package/lib/component/elements/popup/Modal/Provider.js +8 -11
  35. package/lib/component/header/ZeroFillingOptionsPanel.js +3 -1
  36. package/lib/component/hooks/useActiveSpectrumStyleOptions.js +3 -3
  37. package/lib/component/hooks/useDatumWithSpectraStatistics.js +3 -1
  38. package/lib/component/hooks/useExport.d.ts +0 -1
  39. package/lib/component/hooks/useExport.js +1 -17
  40. package/lib/component/hooks/useIntegralPath.js +5 -2
  41. package/lib/component/hooks/useNucleus.js +4 -4
  42. package/lib/component/hooks/useSpectraPerNucleus.js +1 -1
  43. package/lib/component/hooks/useSpectrum.js +3 -1
  44. package/lib/component/loader/DropZone.js +15 -147
  45. package/lib/component/modal/changeSum/SelectMolecule.js +1 -1
  46. package/lib/component/modal/editRange/EditRangeModal.js +1 -1
  47. package/lib/component/modal/setting/GeneralTabContent.js +1 -1
  48. package/lib/component/modal/setting/ToolsTabContent.js +4 -0
  49. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +1 -1
  50. package/lib/component/panels/MoleculesPanel/MoleculeHeader.js +1 -1
  51. package/lib/component/panels/MoleculesPanel/MoleculePanel.js +1 -1
  52. package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -1
  53. package/lib/component/panels/PeaksPanel/PeaksPanel.js +1 -1
  54. package/lib/component/panels/PeaksPanel/PeaksTable.js +1 -1
  55. package/lib/component/panels/RangesPanel/RangesHeader.d.ts +2 -1
  56. package/lib/component/panels/RangesPanel/RangesHeader.js +10 -9
  57. package/lib/component/panels/RangesPanel/RangesPanel.js +7 -3
  58. package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -1
  59. package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.js +3 -1
  60. package/lib/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +3 -26
  61. package/lib/component/panels/SummaryPanel/SummaryPanel.js +1 -1
  62. package/lib/component/panels/SummaryPanel/utilities/useInView.js +3 -1
  63. package/lib/component/panels/ZonesPanel/ZonesPanel.js +19 -10
  64. package/lib/component/panels/databasePanel/DatabasePanel.js +1 -1
  65. package/lib/component/reducer/IgnoreActions.js +1 -0
  66. package/lib/component/reducer/Reducer.d.ts +110 -96
  67. package/lib/component/reducer/Reducer.js +45 -41
  68. package/lib/component/reducer/actions/DomainActions.d.ts +1 -1
  69. package/lib/component/reducer/actions/DomainActions.js +12 -9
  70. package/lib/component/reducer/actions/FiltersActions.d.ts +1 -1
  71. package/lib/component/reducer/actions/FiltersActions.js +227 -232
  72. package/lib/component/reducer/actions/IntegralsActions.js +14 -8
  73. package/lib/component/reducer/actions/LoadActions.d.ts +2 -5
  74. package/lib/component/reducer/actions/LoadActions.js +19 -34
  75. package/lib/component/reducer/actions/MoleculeActions.d.ts +2 -1
  76. package/lib/component/reducer/actions/MoleculeActions.js +22 -6
  77. package/lib/component/reducer/actions/PeaksActions.js +19 -12
  78. package/lib/component/reducer/actions/PreferencesActions.js +9 -10
  79. package/lib/component/reducer/actions/RangesActions.d.ts +4 -4
  80. package/lib/component/reducer/actions/RangesActions.js +89 -29
  81. package/lib/component/reducer/actions/SpectraAnalysisAction.js +5 -5
  82. package/lib/component/reducer/actions/SpectrumsActions.js +14 -10
  83. package/lib/component/reducer/actions/ToolsActions.d.ts +1 -1
  84. package/lib/component/reducer/actions/ToolsActions.js +44 -27
  85. package/lib/component/reducer/actions/ZonesActions.d.ts +4 -1
  86. package/lib/component/reducer/actions/ZonesActions.js +69 -17
  87. package/lib/component/reducer/helper/Zoom1DManager.js +2 -1
  88. package/lib/component/reducer/helper/getActiveSpectrum.d.ts +3 -0
  89. package/lib/component/reducer/helper/getActiveSpectrum.js +4 -0
  90. package/lib/component/reducer/helper/getActiveSpectrumOrFail.d.ts +3 -0
  91. package/lib/component/reducer/helper/getActiveSpectrumOrFail.js +6 -0
  92. package/lib/component/reducer/helper/getSpectrum.js +3 -2
  93. package/lib/component/reducer/helper/getStrongestPeak.js +2 -1
  94. package/lib/component/reducer/preferences/preferencesReducer.d.ts +2 -2
  95. package/lib/component/reducer/types/Types.d.ts +5 -0
  96. package/lib/component/reducer/types/Types.js +5 -0
  97. package/lib/component/tool/FloatMoleculeStructures/DraggableStructure.d.ts +6 -0
  98. package/lib/component/tool/FloatMoleculeStructures/DraggableStructure.js +10 -3
  99. package/lib/component/tool/FloatMoleculeStructures/index.js +14 -8
  100. package/lib/component/toolbar/BasicToolBar.js +12 -13
  101. package/lib/component/toolbar/FunctionToolBar.js +3 -1
  102. package/lib/component/utility/Export.js +7 -1
  103. package/lib/component/utility/assert.d.ts +1 -0
  104. package/lib/component/utility/assert.js +5 -0
  105. package/lib/component/workspaces/Workspace.d.ts +1 -1
  106. package/lib/component/workspaces/exercise.js +9 -3
  107. package/lib/component/workspaces/workspaceDefaultProperties.js +1 -1
  108. package/lib/data/Filters.d.ts +1 -2
  109. package/lib/data/Filters.js +1 -2
  110. package/lib/data/SpectraManager.d.ts +0 -4
  111. package/lib/data/SpectraManager.js +2 -87
  112. package/lib/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +1 -0
  113. package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +1 -0
  114. package/lib/data/data1d/filter1d/fft.js +11 -0
  115. package/lib/data/data1d/filter1d/phaseCorrection.js +11 -5
  116. package/lib/data/data1d/filter1d/utils/padDataToNextPowerOfTwo.d.ts +2 -0
  117. package/lib/data/data1d/filter1d/utils/padDataToNextPowerOfTwo.js +35 -0
  118. package/lib/data/data2d/Processing2D.js +3 -2
  119. package/lib/data/data2d/Spectrum2D/zones/getDetectionZones.d.ts +1 -1
  120. package/lib/data/molecules/Molecule.d.ts +5 -0
  121. package/lib/data/utilities/calculateSanPlot.d.ts +8 -0
  122. package/lib/data/utilities/calculateSanPlot.js +31 -0
  123. package/lib/types/NMRiumGeneralPreferences.d.ts +2 -2
  124. package/lib/versionInfo.js +1 -1
  125. package/lib-cjs/component/1d/ApodizationLine.js +3 -1
  126. package/lib-cjs/component/1d/FooterBanner.js +19 -10
  127. package/lib-cjs/component/1d/IntegralsSeries.js +3 -1
  128. package/lib-cjs/component/1d/LinesSeries.js +3 -1
  129. package/lib-cjs/component/1d/SpectraTracker.js +1 -1
  130. package/lib-cjs/component/1d/Viewer1D.js +3 -1
  131. package/lib-cjs/component/1d/jCouplingGraph/JGraph.js +5 -1
  132. package/lib-cjs/component/1d/multiAnalysis/MultiAnalysisRanges.js +1 -1
  133. package/lib-cjs/component/1d/multiplicityTree/MultiplicityTree.js +3 -1
  134. package/lib-cjs/component/1d/peaks/PeakAnnotations.js +3 -1
  135. package/lib-cjs/component/1d/peaks/PeaksShapes.js +4 -2
  136. package/lib-cjs/component/1d/peaks/usePeakShapesPath.js +7 -3
  137. package/lib-cjs/component/1d/ranges/Ranges.js +7 -1
  138. package/lib-cjs/component/1d/tool/PeakPointer.js +3 -1
  139. package/lib-cjs/component/1d/tool/XLabelPointer.js +3 -1
  140. package/lib-cjs/component/2d/Contours.js +4 -2
  141. package/lib-cjs/component/2d/FooterBanner.js +3 -1
  142. package/lib-cjs/component/2d/Left1DChart.js +1 -1
  143. package/lib-cjs/component/2d/Top1DChart.js +1 -1
  144. package/lib-cjs/component/2d/Viewer2D.js +4 -4
  145. package/lib-cjs/component/2d/XAxis.js +2 -2
  146. package/lib-cjs/component/2d/YAxis.js +2 -2
  147. package/lib-cjs/component/2d/tools/XYLabelPointer.js +3 -1
  148. package/lib-cjs/component/2d/tools/slicing/SlicingView.js +3 -1
  149. package/lib-cjs/component/2d/zones/IndicationLines.js +1 -1
  150. package/lib-cjs/component/2d/zones/Zones.js +13 -18
  151. package/lib-cjs/component/EventsTrackers/BrushTracker.js +30 -21
  152. package/lib-cjs/component/NMRium.js +14 -3
  153. package/lib-cjs/component/SplitPaneWrapper.js +1 -1
  154. package/lib-cjs/component/elements/EditableColumn.js +18 -3
  155. package/lib-cjs/component/elements/popup/Modal/Provider.js +8 -11
  156. package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +3 -1
  157. package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +3 -3
  158. package/lib-cjs/component/hooks/useDatumWithSpectraStatistics.js +3 -1
  159. package/lib-cjs/component/hooks/useExport.js +0 -16
  160. package/lib-cjs/component/hooks/useIntegralPath.js +5 -2
  161. package/lib-cjs/component/hooks/useNucleus.js +4 -4
  162. package/lib-cjs/component/hooks/useSpectraPerNucleus.js +1 -1
  163. package/lib-cjs/component/hooks/useSpectrum.js +3 -1
  164. package/lib-cjs/component/loader/DropZone.js +14 -149
  165. package/lib-cjs/component/modal/changeSum/SelectMolecule.js +1 -1
  166. package/lib-cjs/component/modal/editRange/EditRangeModal.js +1 -1
  167. package/lib-cjs/component/modal/setting/GeneralTabContent.js +1 -1
  168. package/lib-cjs/component/modal/setting/ToolsTabContent.js +4 -0
  169. package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +1 -1
  170. package/lib-cjs/component/panels/MoleculesPanel/MoleculeHeader.js +1 -1
  171. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanel.js +1 -1
  172. package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -1
  173. package/lib-cjs/component/panels/PeaksPanel/PeaksPanel.js +1 -1
  174. package/lib-cjs/component/panels/PeaksPanel/PeaksTable.js +1 -1
  175. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +10 -9
  176. package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +7 -3
  177. package/lib-cjs/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -1
  178. package/lib-cjs/component/panels/SpectrumsPanel/SpectrumsTabs.js +3 -1
  179. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -25
  180. package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +1 -1
  181. package/lib-cjs/component/panels/SummaryPanel/utilities/useInView.js +3 -1
  182. package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +18 -9
  183. package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +1 -1
  184. package/lib-cjs/component/reducer/IgnoreActions.js +1 -0
  185. package/lib-cjs/component/reducer/Reducer.js +48 -43
  186. package/lib-cjs/component/reducer/actions/DomainActions.js +12 -9
  187. package/lib-cjs/component/reducer/actions/FiltersActions.js +228 -233
  188. package/lib-cjs/component/reducer/actions/IntegralsActions.js +14 -8
  189. package/lib-cjs/component/reducer/actions/LoadActions.js +18 -36
  190. package/lib-cjs/component/reducer/actions/MoleculeActions.js +23 -6
  191. package/lib-cjs/component/reducer/actions/PeaksActions.js +19 -12
  192. package/lib-cjs/component/reducer/actions/PreferencesActions.js +9 -10
  193. package/lib-cjs/component/reducer/actions/RangesActions.js +89 -29
  194. package/lib-cjs/component/reducer/actions/SpectraAnalysisAction.js +5 -5
  195. package/lib-cjs/component/reducer/actions/SpectrumsActions.js +14 -10
  196. package/lib-cjs/component/reducer/actions/ToolsActions.js +44 -27
  197. package/lib-cjs/component/reducer/actions/ZonesActions.js +72 -17
  198. package/lib-cjs/component/reducer/helper/Zoom1DManager.js +2 -1
  199. package/lib-cjs/component/reducer/helper/getActiveSpectrum.js +8 -0
  200. package/lib-cjs/component/reducer/helper/getActiveSpectrumOrFail.js +10 -0
  201. package/lib-cjs/component/reducer/helper/getSpectrum.js +3 -2
  202. package/lib-cjs/component/reducer/helper/getStrongestPeak.js +2 -1
  203. package/lib-cjs/component/reducer/types/Types.js +8 -3
  204. package/lib-cjs/component/tool/FloatMoleculeStructures/DraggableStructure.js +10 -3
  205. package/lib-cjs/component/tool/FloatMoleculeStructures/index.js +14 -8
  206. package/lib-cjs/component/toolbar/BasicToolBar.js +11 -12
  207. package/lib-cjs/component/toolbar/FunctionToolBar.js +3 -1
  208. package/lib-cjs/component/utility/Export.js +7 -1
  209. package/lib-cjs/component/utility/assert.js +9 -0
  210. package/lib-cjs/component/workspaces/exercise.js +9 -3
  211. package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +1 -1
  212. package/lib-cjs/data/Filters.js +1 -3
  213. package/lib-cjs/data/SpectraManager.js +3 -92
  214. package/lib-cjs/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +1 -0
  215. package/lib-cjs/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +1 -0
  216. package/lib-cjs/data/data1d/filter1d/fft.js +11 -0
  217. package/lib-cjs/data/data1d/filter1d/phaseCorrection.js +10 -4
  218. package/lib-cjs/data/data1d/filter1d/utils/padDataToNextPowerOfTwo.js +39 -0
  219. package/lib-cjs/data/data2d/Processing2D.js +3 -2
  220. package/lib-cjs/data/utilities/calculateSanPlot.js +35 -0
  221. package/lib-cjs/versionInfo.js +1 -1
  222. package/package.json +26 -25
  223. package/lib/component/utility/nmredataToNmrium.d.ts +0 -4
  224. package/lib/component/utility/nmredataToNmrium.js +0 -66
  225. package/lib/component/utility/nmriumToNmredata.d.ts +0 -2
  226. package/lib/component/utility/nmriumToNmredata.js +0 -80
  227. package/lib/component/utility/util/nmredata/addRanges.d.ts +0 -1
  228. package/lib/component/utility/util/nmredata/addRanges.js +0 -52
  229. package/lib/component/utility/util/nmredata/addSource.d.ts +0 -6
  230. package/lib/component/utility/util/nmredata/addSource.js +0 -54
  231. package/lib/component/utility/util/nmredata/addZones.d.ts +0 -1
  232. package/lib/component/utility/util/nmredata/addZones.js +0 -41
  233. package/lib/component/utility/util/nmredata/flat2DSignals.d.ts +0 -1
  234. package/lib/component/utility/util/nmredata/flat2DSignals.js +0 -7
  235. package/lib/component/utility/util/nmredata/get1DSignals.d.ts +0 -10
  236. package/lib/component/utility/util/nmredata/get1DSignals.js +0 -96
  237. package/lib/component/utility/util/nmredata/get2DSignals.d.ts +0 -8
  238. package/lib/component/utility/util/nmredata/get2DSignals.js +0 -59
  239. package/lib/component/utility/util/nmredata/getCouplingObserved.d.ts +0 -1
  240. package/lib/component/utility/util/nmredata/getCouplingObserved.js +0 -11
  241. package/lib/component/utility/util/nmredata/getLabels.d.ts +0 -9
  242. package/lib/component/utility/util/nmredata/getLabels.js +0 -66
  243. package/lib/component/utility/util/nmredata/getToFix.d.ts +0 -1
  244. package/lib/component/utility/util/nmredata/getToFix.js +0 -19
  245. package/lib/data/data1d/filter1d/absolute.d.ts +0 -13
  246. package/lib/data/data1d/filter1d/absolute.js +0 -26
  247. package/lib/data/migration/MigrationManager.d.ts +0 -2
  248. package/lib/data/migration/MigrationManager.js +0 -19
  249. package/lib/data/migration/changeKeys.d.ts +0 -1
  250. package/lib/data/migration/changeKeys.js +0 -9
  251. package/lib/data/migration/migrateToVersion1.d.ts +0 -11
  252. package/lib/data/migration/migrateToVersion1.js +0 -32
  253. package/lib/data/migration/migrateToVersion2.d.ts +0 -1
  254. package/lib/data/migration/migrateToVersion2.js +0 -111
  255. package/lib/data/migration/migrateToVersion3.d.ts +0 -1
  256. package/lib/data/migration/migrateToVersion3.js +0 -55
  257. package/lib-cjs/component/utility/nmredataToNmrium.js +0 -73
  258. package/lib-cjs/component/utility/nmriumToNmredata.js +0 -87
  259. package/lib-cjs/component/utility/util/nmredata/addRanges.js +0 -56
  260. package/lib-cjs/component/utility/util/nmredata/addSource.js +0 -61
  261. package/lib-cjs/component/utility/util/nmredata/addZones.js +0 -45
  262. package/lib-cjs/component/utility/util/nmredata/flat2DSignals.js +0 -11
  263. package/lib-cjs/component/utility/util/nmredata/get1DSignals.js +0 -100
  264. package/lib-cjs/component/utility/util/nmredata/get2DSignals.js +0 -63
  265. package/lib-cjs/component/utility/util/nmredata/getCouplingObserved.js +0 -15
  266. package/lib-cjs/component/utility/util/nmredata/getLabels.js +0 -70
  267. package/lib-cjs/component/utility/util/nmredata/getToFix.js +0 -23
  268. package/lib-cjs/data/data1d/filter1d/absolute.js +0 -32
  269. package/lib-cjs/data/migration/MigrationManager.js +0 -26
  270. package/lib-cjs/data/migration/changeKeys.js +0 -13
  271. package/lib-cjs/data/migration/migrateToVersion1.js +0 -35
  272. package/lib-cjs/data/migration/migrateToVersion2.js +0 -114
  273. package/lib-cjs/data/migration/migrateToVersion3.js +0 -58
@@ -13,6 +13,7 @@ import { options } from '../../toolbar/ToolTypes';
13
13
  import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
14
14
  import nucleusToString from '../../utility/nucleusToString';
15
15
  import zoomHistoryManager from '../helper/ZoomHistoryManager';
16
+ import { getActiveSpectrumOrFail } from '../helper/getActiveSpectrumOrFail';
16
17
  import getRange from '../helper/getRange';
17
18
  import { getStrongestPeak } from '../helper/getStrongestPeak';
18
19
  import { setDomain, setMode } from './DomainActions';
@@ -20,202 +21,198 @@ import { changeSpectrumVerticalAlignment } from './PreferencesActions';
20
21
  import { resetSelectedTool } from './ToolsActions';
21
22
  function shiftSpectrumAlongXAxis(draft, shiftValue) {
22
23
  //apply filter into the spectrum
23
- if (draft.activeSpectrum?.id) {
24
- const index = draft.activeSpectrum?.index;
25
- FiltersManager.applyFilter(draft.data[index], [
26
- { name: Filters.shiftX.id, options: shiftValue },
27
- ]);
28
- updateXShift(draft.data[index]);
29
- resetSelectedTool(draft);
30
- setDomain(draft);
31
- }
24
+ const activeSpectrum = getActiveSpectrumOrFail(draft);
25
+ const index = activeSpectrum?.index;
26
+ FiltersManager.applyFilter(draft.data[index], [
27
+ { name: Filters.shiftX.id, options: shiftValue },
28
+ ]);
29
+ updateXShift(draft.data[index]);
30
+ resetSelectedTool(draft);
31
+ setDomain(draft);
32
32
  }
33
33
  function applyZeroFillingFilter(draft, action) {
34
- if (draft.activeSpectrum?.id) {
35
- const index = draft.activeSpectrum.index;
36
- const { size } = action.payload;
37
- const filters = [
38
- {
39
- name: Filters.zeroFilling.id,
40
- options: size,
41
- },
42
- ];
43
- FiltersManager.applyFilter(draft.data[index], filters);
44
- resetSelectedTool(draft);
45
- setDomain(draft);
46
- setMode(draft);
47
- }
34
+ const activeSpectrum = getActiveSpectrumOrFail(draft);
35
+ const index = activeSpectrum.index;
36
+ const { size } = action.payload;
37
+ const filters = [
38
+ {
39
+ name: Filters.zeroFilling.id,
40
+ options: size,
41
+ },
42
+ ];
43
+ FiltersManager.applyFilter(draft.data[index], filters);
44
+ resetSelectedTool(draft);
45
+ setDomain(draft);
46
+ setMode(draft);
48
47
  }
49
48
  function calculateApodizationFilter(draft, action) {
50
- if (draft.activeSpectrum) {
51
- const index = draft.activeSpectrum.index;
52
- const options = action.payload;
53
- const { data: { x, re, im }, info, } = draft.data[index];
54
- let _data = { data: { x, re, im }, info };
55
- draft.toolOptions.data.apodizationOptions = options;
56
- apodization(_data, options);
57
- const { im: newIm, re: newRe } = _data.data;
58
- draft.tempData[index].data.im = newIm;
59
- draft.tempData[index].data.re = newRe;
60
- }
49
+ const activeSpectrum = getActiveSpectrumOrFail(draft);
50
+ const index = activeSpectrum.index;
51
+ const options = action.payload;
52
+ const { data: { x, re, im }, info, } = draft.data[index];
53
+ let _data = { data: { x, re, im }, info };
54
+ draft.toolOptions.data.apodizationOptions = options;
55
+ apodization(_data, options);
56
+ const { im: newIm, re: newRe } = _data.data;
57
+ draft.tempData[index].data.im = newIm;
58
+ draft.tempData[index].data.re = newRe;
61
59
  }
62
60
  function applyApodizationFilter(draft, action) {
63
- if (draft.activeSpectrum?.id) {
64
- const index = draft.activeSpectrum.index;
65
- const options = action.payload;
66
- const filters = [
67
- {
68
- name: Filters.apodization.id,
69
- options,
70
- },
71
- ];
72
- FiltersManager.applyFilter(draft.data[index], filters);
73
- resetSelectedTool(draft);
74
- setDomain(draft);
75
- setMode(draft);
76
- }
61
+ const activeSpectrum = getActiveSpectrumOrFail(draft);
62
+ const index = activeSpectrum.index;
63
+ const options = action.payload;
64
+ const filters = [
65
+ {
66
+ name: Filters.apodization.id,
67
+ options,
68
+ },
69
+ ];
70
+ FiltersManager.applyFilter(draft.data[index], filters);
71
+ resetSelectedTool(draft);
72
+ setDomain(draft);
73
+ setMode(draft);
77
74
  }
78
75
  function calculateZeroFillingFilter(draft, action) {
79
- if (draft.activeSpectrum) {
80
- const index = draft.activeSpectrum.index;
81
- const { size } = action.payload;
82
- const { data: { x, re, im }, filters, info, } = draft.data[index];
83
- let _data = { data: { x, re, im }, filters, info };
84
- zeroFilling(_data, size);
85
- const { im: newIm, re: newRe, x: newX } = _data.data;
86
- draft.tempData[index].data.x = newX;
87
- draft.tempData[index].data.im = newIm;
88
- draft.tempData[index].data.re = newRe;
89
- draft.xDomain = [newX[0], newX[newX.length - 1]];
90
- }
76
+ const activeSpectrum = getActiveSpectrumOrFail(draft);
77
+ const index = activeSpectrum.index;
78
+ const { size } = action.payload;
79
+ const { data: { x, re, im }, filters, info, } = draft.data[index];
80
+ let _data = { data: { x, re, im }, filters, info };
81
+ zeroFilling(_data, size);
82
+ const { im: newIm, re: newRe, x: newX } = _data.data;
83
+ draft.tempData[index].data.x = newX;
84
+ draft.tempData[index].data.im = newIm;
85
+ draft.tempData[index].data.re = newRe;
86
+ draft.xDomain = [newX[0], newX[newX.length - 1]];
91
87
  }
92
88
  function applyFFTFilter(draft) {
93
- if (draft.activeSpectrum?.id) {
94
- const { index } = draft.activeSpectrum;
95
- //apply filter into the spectrum
96
- FiltersManager.applyFilter(draft.data[index], [
97
- { name: Filters.fft.id, options: {} },
98
- ]);
99
- resetSelectedTool(draft);
100
- changeSpectrumVerticalAlignment(draft, { align: 'bottom' });
101
- setDomain(draft, { yDomain: { isChanged: true } });
102
- setMode(draft);
103
- }
89
+ const activeSpectrum = getActiveSpectrumOrFail(draft);
90
+ const { index } = activeSpectrum;
91
+ //apply filter into the spectrum
92
+ FiltersManager.applyFilter(draft.data[index], [
93
+ { name: Filters.fft.id, options: {} },
94
+ ]);
95
+ resetSelectedTool(draft);
96
+ changeSpectrumVerticalAlignment(draft, { align: 'bottom' });
97
+ setDomain(draft, { yDomain: { isChanged: true } });
98
+ setMode(draft);
104
99
  }
105
100
  function applyManualPhaseCorrectionFilter(draft, filterOptions) {
106
- if (draft.activeSpectrum?.id) {
107
- const { index } = draft.activeSpectrum;
108
- const { ph0, ph1 } = filterOptions;
109
- FiltersManager.applyFilter(draft.data[index], [
110
- { name: Filters.phaseCorrection.id, options: { ph0, ph1 } },
111
- ]);
112
- resetSelectedTool(draft);
113
- draft.tempData = null;
114
- setDomain(draft);
115
- }
101
+ const activeSpectrum = getActiveSpectrumOrFail(draft);
102
+ const { index } = activeSpectrum;
103
+ const { ph0, ph1 } = filterOptions;
104
+ FiltersManager.applyFilter(draft.data[index], [
105
+ {
106
+ name: Filters.phaseCorrection.id,
107
+ options: { ph0, ph1, absolute: false },
108
+ },
109
+ ]);
110
+ resetSelectedTool(draft);
111
+ draft.tempData = null;
112
+ setDomain(draft);
116
113
  }
117
114
  function applyAbsoluteFilter(draft) {
118
- if (draft.activeSpectrum?.id) {
119
- const { index } = draft.activeSpectrum;
120
- FiltersManager.applyFilter(draft.data[index], [
121
- { name: Filters.absolute.id, options: {} },
122
- ]);
123
- resetSelectedTool(draft);
124
- draft.tempData = null;
125
- setDomain(draft);
126
- }
115
+ const activeSpectrum = getActiveSpectrumOrFail(draft);
116
+ const { index } = activeSpectrum;
117
+ FiltersManager.applyFilter(draft.data[index], [
118
+ {
119
+ name: Filters.phaseCorrection.id,
120
+ options: { absolute: true, ph0: 0, ph1: 0 },
121
+ },
122
+ ]);
123
+ resetSelectedTool(draft);
124
+ draft.tempData = null;
125
+ setDomain(draft);
127
126
  }
128
127
  function applyAutoPhaseCorrectionFilter(draft) {
129
- if (draft.activeSpectrum?.id) {
130
- const { index } = draft.activeSpectrum;
131
- const { ph0, ph1 } = autoPhaseCorrection(draft.data[index]);
132
- FiltersManager.applyFilter(draft.data[index], [
133
- { name: Filters.phaseCorrection.id, options: { ph0, ph1 } },
134
- ]);
135
- resetSelectedTool(draft);
136
- draft.tempData = null;
137
- setDomain(draft);
138
- }
128
+ const activeSpectrum = getActiveSpectrumOrFail(draft);
129
+ const { index } = activeSpectrum;
130
+ const { ph0, ph1 } = autoPhaseCorrection(draft.data[index]);
131
+ FiltersManager.applyFilter(draft.data[index], [
132
+ {
133
+ name: Filters.phaseCorrection.id,
134
+ options: { ph0, ph1, absolute: false },
135
+ },
136
+ ]);
137
+ resetSelectedTool(draft);
138
+ draft.tempData = null;
139
+ setDomain(draft);
139
140
  }
140
141
  function calculateBaseLineCorrection(draft, action) {
141
- if (draft.activeSpectrum) {
142
- const { index } = draft.activeSpectrum;
143
- const { data: { x, re, im }, info, } = draft.data[index];
144
- // save the baseline options temporary
145
- draft.toolOptions.data.baselineCorrection = {
146
- ...draft.toolOptions.data.baselineCorrection,
147
- ...(action?.options ? { options: action.options } : {}),
148
- };
149
- const { zones, options } = draft.toolOptions.data.baselineCorrection;
150
- const { livePreview, ...filterOptions } = options;
151
- if (livePreview) {
152
- let _data = { data: { x, re, im }, info };
153
- baselineCorrection(_data, {
154
- zones,
155
- ...filterOptions,
156
- });
157
- const { im: newIm, re: newRe } = _data.data;
158
- draft.tempData[index].data.im = newIm;
159
- draft.tempData[index].data.re = newRe;
160
- }
161
- }
162
- }
163
- function calculateManualPhaseCorrection(draft, filterOptions) {
164
- if (draft.activeSpectrum) {
165
- const { index } = draft.activeSpectrum;
166
- const { data: { x, re, im }, info, } = draft.data[index];
167
- const { ph0, ph1 } = filterOptions;
142
+ const activeSpectrum = getActiveSpectrumOrFail(draft);
143
+ const { index } = activeSpectrum;
144
+ const { data: { x, re, im }, info, } = draft.data[index];
145
+ // save the baseline options temporary
146
+ draft.toolOptions.data.baselineCorrection = {
147
+ ...draft.toolOptions.data.baselineCorrection,
148
+ ...(action?.options ? { options: action.options } : {}),
149
+ };
150
+ const { zones, options } = draft.toolOptions.data.baselineCorrection;
151
+ const { livePreview, ...filterOptions } = options;
152
+ if (livePreview) {
168
153
  let _data = { data: { x, re, im }, info };
169
- phaseCorrection(_data, { ph0, ph1 });
154
+ baselineCorrection(_data, {
155
+ zones,
156
+ ...filterOptions,
157
+ });
170
158
  const { im: newIm, re: newRe } = _data.data;
171
159
  draft.tempData[index].data.im = newIm;
172
160
  draft.tempData[index].data.re = newRe;
173
161
  }
174
162
  }
163
+ function calculateManualPhaseCorrection(draft, filterOptions) {
164
+ const activeSpectrum = getActiveSpectrumOrFail(draft);
165
+ const { index } = activeSpectrum;
166
+ const { data: { x, re, im }, info, } = draft.data[index];
167
+ const { ph0, ph1 } = filterOptions;
168
+ let _data = { data: { x, re, im }, info };
169
+ phaseCorrection(_data, { ph0, ph1 });
170
+ const { im: newIm, re: newRe } = _data.data;
171
+ draft.tempData[index].data.im = newIm;
172
+ draft.tempData[index].data.re = newRe;
173
+ }
175
174
  function enableFilter(draft, filterID, checked) {
176
- if (draft.activeSpectrum?.id) {
177
- const { index } = draft.activeSpectrum;
178
- //apply filter into the spectrum
179
- FiltersManager.enableFilter(draft.data[index], filterID, checked);
180
- if (draft.data[index].info?.dimension === 1) {
181
- updateXShift(draft.data[index]);
182
- }
183
- else if (draft.data[index].info?.dimension === 2) {
184
- update2dShift(draft.data[index]);
185
- }
186
- resetSelectedTool(draft);
187
- setDomain(draft);
188
- setMode(draft);
189
- const zoomHistory = zoomHistoryManager(draft.zoom.history, draft.activeTab);
190
- const zoomValue = zoomHistory.getLast();
191
- if (zoomValue) {
192
- draft.xDomain = zoomValue.xDomain;
193
- draft.yDomain = zoomValue.yDomain;
194
- }
175
+ const activeSpectrum = getActiveSpectrumOrFail(draft);
176
+ const { index } = activeSpectrum;
177
+ //apply filter into the spectrum
178
+ FiltersManager.enableFilter(draft.data[index], filterID, checked);
179
+ if (draft.data[index].info?.dimension === 1) {
180
+ updateXShift(draft.data[index]);
181
+ }
182
+ else if (draft.data[index].info?.dimension === 2) {
183
+ update2dShift(draft.data[index]);
184
+ }
185
+ resetSelectedTool(draft);
186
+ setDomain(draft);
187
+ setMode(draft);
188
+ const zoomHistory = zoomHistoryManager(draft.zoom.history, draft.view.spectra.activeTab);
189
+ const zoomValue = zoomHistory.getLast();
190
+ if (zoomValue) {
191
+ draft.xDomain = zoomValue.xDomain;
192
+ draft.yDomain = zoomValue.yDomain;
195
193
  }
196
194
  }
197
195
  function deleteFilter(draft, actions) {
198
196
  const filterID = actions.payload.id;
199
- if (draft.activeSpectrum?.id) {
200
- const { index } = draft.activeSpectrum;
201
- //apply filter into the spectrum
202
- FiltersManager.deleteFilter(draft.data[index], filterID);
203
- if (draft.data[index].info?.dimension === 1) {
204
- updateXShift(draft.data[index]);
205
- }
206
- else if (draft.data[index].info?.dimension === 2) {
207
- update2dShift(draft.data[index]);
208
- }
209
- resetSelectedTool(draft);
210
- setDomain(draft);
211
- setMode(draft);
197
+ const activeSpectrum = getActiveSpectrumOrFail(draft);
198
+ const { index } = activeSpectrum;
199
+ //apply filter into the spectrum
200
+ FiltersManager.deleteFilter(draft.data[index], filterID);
201
+ if (draft.data[index].info?.dimension === 1) {
202
+ updateXShift(draft.data[index]);
212
203
  }
204
+ else if (draft.data[index].info?.dimension === 2) {
205
+ update2dShift(draft.data[index]);
206
+ }
207
+ resetSelectedTool(draft);
208
+ setDomain(draft);
209
+ setMode(draft);
213
210
  }
214
211
  function deleteSpectraFilter(draft, actions) {
215
212
  const filterType = actions.payload.filterType;
216
- if (draft.activeTab) {
213
+ if (draft.view.spectra.activeTab) {
217
214
  for (const datum of draft.data) {
218
- if (nucleusToString(datum?.info?.nucleus) === draft.activeTab) {
215
+ if (nucleusToString(datum?.info?.nucleus) === draft.view.spectra.activeTab) {
219
216
  const filtersResult = datum.filters?.filter((filter) => filter.name === filterType) || [];
220
217
  filtersResult.forEach((filter) => {
221
218
  FiltersManager.deleteFilter(datum, filter.id);
@@ -234,24 +231,23 @@ function deleteSpectraFilter(draft, actions) {
234
231
  }
235
232
  }
236
233
  function handleBaseLineCorrectionFilter(draft, action) {
237
- if (draft.activeSpectrum?.id) {
238
- const { index } = draft.activeSpectrum;
239
- const { zones } = draft.toolOptions.data.baselineCorrection;
240
- const { livePreview, ...options } = action.options;
241
- FiltersManager.applyFilter(draft.data[index], [
242
- {
243
- name: Filters.baselineCorrection.id,
244
- options: {
245
- zones,
246
- ...options,
247
- },
234
+ const activeSpectrum = getActiveSpectrumOrFail(draft);
235
+ const { index } = activeSpectrum;
236
+ const { zones } = draft.toolOptions.data.baselineCorrection;
237
+ const { livePreview, ...options } = action.options;
238
+ FiltersManager.applyFilter(draft.data[index], [
239
+ {
240
+ name: Filters.baselineCorrection.id,
241
+ options: {
242
+ zones,
243
+ ...options,
248
244
  },
249
- ]);
250
- const xDomainSnapshot = draft.xDomain.slice();
251
- resetSelectedTool(draft);
252
- setDomain(draft);
253
- draft.xDomain = xDomainSnapshot;
254
- }
245
+ },
246
+ ]);
247
+ const xDomainSnapshot = draft.xDomain.slice();
248
+ resetSelectedTool(draft);
249
+ setDomain(draft);
250
+ draft.xDomain = xDomainSnapshot;
255
251
  }
256
252
  /**
257
253
  * reset spectrum data for specific point of time (Filter)
@@ -266,48 +262,46 @@ function resetSpectrumByFilter(draft, options) {
266
262
  const { updateDomain = true, rollback = false, searchBy = 'id', applyFilter = false, // the filter that we rollback and return the affect data for the selected spectrum
267
263
  filterId, } = options || {};
268
264
  let currentDatum = null;
269
- const currentActiveSpectrum = draft.activeSpectrum;
270
- if (currentActiveSpectrum?.id) {
271
- const index = currentActiveSpectrum.index;
272
- const datum = draft.data[index];
273
- if (filterId && draft.toolOptions.data.activeFilterID !== filterId) {
274
- const filterIndex = datum.filters.findIndex((f) => f[searchBy] === filterId);
275
- let filters = [];
276
- if (filterIndex !== -1) {
277
- filters = datum.filters.slice(0, rollback ? filterIndex : filterIndex + 1);
278
- if (filters.length >= 1) {
279
- draft.toolOptions.data.activeFilterID =
280
- datum.filters[rollback ? filterIndex - 1 : filterIndex]?.id;
281
- }
282
- else {
283
- draft.toolOptions.data.activeFilterID = null;
284
- }
285
- FiltersManager.reapplyFilters(datum, filters);
286
- if (applyFilter) {
287
- const { name, value: options } = datum.filters[filterIndex];
288
- const newDatum = current(draft).data[index];
289
- if (newDatum.info?.dimension === 1) {
290
- FiltersManager.applyFilter(newDatum, [{ name, options }]);
291
- }
292
- currentDatum = { datum: newDatum, index };
265
+ const currentActiveSpectrum = getActiveSpectrumOrFail(draft);
266
+ const index = currentActiveSpectrum.index;
267
+ const datum = draft.data[index];
268
+ if (filterId && draft.toolOptions.data.activeFilterID !== filterId) {
269
+ const filterIndex = datum.filters.findIndex((f) => f[searchBy] === filterId);
270
+ let filters = [];
271
+ if (filterIndex !== -1) {
272
+ filters = datum.filters.slice(0, rollback ? filterIndex : filterIndex + 1);
273
+ if (filters.length >= 1) {
274
+ draft.toolOptions.data.activeFilterID =
275
+ datum.filters[rollback ? filterIndex - 1 : filterIndex]?.id;
276
+ }
277
+ else {
278
+ draft.toolOptions.data.activeFilterID = null;
279
+ }
280
+ FiltersManager.reapplyFilters(datum, filters);
281
+ if (applyFilter) {
282
+ const { name, value: options } = datum.filters[filterIndex];
283
+ const newDatum = current(draft).data[index];
284
+ if (newDatum.info?.dimension === 1) {
285
+ FiltersManager.applyFilter(newDatum, [{ name, options }]);
293
286
  }
287
+ currentDatum = { datum: newDatum, index };
294
288
  }
295
289
  }
296
- else {
297
- //close filter snapshot mode and replay all enabled filters
298
- draft.toolOptions.data.activeFilterID = null;
299
- FiltersManager.reapplyFilters(datum);
300
- }
301
- if (datum.info?.dimension === 1) {
302
- updateXShift(datum);
303
- }
304
- else if (datum.info?.dimension === 2) {
305
- update2dShift(datum);
306
- }
307
- if (updateDomain) {
308
- setDomain(draft);
309
- setMode(draft);
310
- }
290
+ }
291
+ else {
292
+ //close filter snapshot mode and replay all enabled filters
293
+ draft.toolOptions.data.activeFilterID = null;
294
+ FiltersManager.reapplyFilters(datum);
295
+ }
296
+ if (datum.info?.dimension === 1) {
297
+ updateXShift(datum);
298
+ }
299
+ else if (datum.info?.dimension === 2) {
300
+ update2dShift(datum);
301
+ }
302
+ if (updateDomain) {
303
+ setDomain(draft);
304
+ setMode(draft);
311
305
  }
312
306
  if (applyFilter) {
313
307
  return currentDatum;
@@ -318,7 +312,7 @@ function filterSnapshotHandler(draft, action) {
318
312
  resetSpectrumByFilter(draft, { filterId });
319
313
  }
320
314
  function handleMultipleSpectraFilter(draft, action) {
321
- const spectra = getSpectraByNucleus(draft.activeTab, draft.data);
315
+ const spectra = getSpectraByNucleus(draft.view.spectra.activeTab, draft.data);
322
316
  if (spectra && spectra.length > 0 && Array.isArray(action.payload)) {
323
317
  const exclusions = spectra[0].filters.find((f) => f.name === Filters.exclusionZones.id)
324
318
  ?.value || [];
@@ -341,12 +335,14 @@ function handleAddExclusionZone(draft, action) {
341
335
  const { from: startX, to: endX } = action.payload;
342
336
  const range = getRange(draft, { startX, endX });
343
337
  let spectra;
344
- if (draft.activeSpectrum?.id) {
345
- const index = draft.activeSpectrum?.index;
338
+ // todo: refactor this
339
+ const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
340
+ if (activeSpectrum?.id) {
341
+ const index = activeSpectrum?.index;
346
342
  spectra = [draft.data[index]];
347
343
  }
348
344
  else {
349
- spectra = getSpectraByNucleus(draft.activeTab, draft.data);
345
+ spectra = getSpectraByNucleus(draft.view.spectra.activeTab, draft.data);
350
346
  }
351
347
  for (const spectrum of spectra) {
352
348
  FiltersManager.applyFilter(spectrum, [
@@ -382,7 +378,7 @@ function handleDeleteExclusionZone(draft, action) {
382
378
  }
383
379
  else {
384
380
  // remove all exclusive zone that have the same range in all spectra
385
- const data = getSpectraByNucleus(draft.activeTab, draft.data);
381
+ const data = getSpectraByNucleus(draft.view.spectra.activeTab, draft.data);
386
382
  for (const datum of data) {
387
383
  for (const filter of datum.filters) {
388
384
  if (filter.name === Filters.exclusionZones.id) {
@@ -409,7 +405,8 @@ function checkFilterHasTempData(selectedToolId) {
409
405
  ].includes(selectedToolId);
410
406
  }
411
407
  function setFilterChanges(draft, selectedFilterID) {
412
- const activeSpectrumId = draft.activeSpectrum?.id;
408
+ const activeSpectrum = getActiveSpectrumOrFail(draft);
409
+ const activeSpectrumId = activeSpectrum.id;
413
410
  // If the user selects the filter from the filters list or selects its tool and has a record in the filter list for preview and edit
414
411
  if (checkFilterHasTempData(selectedFilterID)) {
415
412
  //return back the spectra data to point of time before applying a specific filter
@@ -441,14 +438,12 @@ function setFilterChanges(draft, selectedFilterID) {
441
438
  break;
442
439
  }
443
440
  case options.baselineCorrection.id: {
444
- if (draft.activeSpectrum?.id) {
445
- const baselineCorrectionFilter = current(draft).data[draft.activeSpectrum.index].filters.find((filter) => filter.name === options.baselineCorrection.id);
446
- if (baselineCorrectionFilter) {
447
- draft.toolOptions.data.baselineCorrection.zones =
448
- baselineCorrectionFilter
449
- ? baselineCorrectionFilter.value.zones
450
- : [];
451
- }
441
+ const baselineCorrectionFilter = current(draft).data[activeSpectrum.index].filters.find((filter) => filter.name === options.baselineCorrection.id);
442
+ if (baselineCorrectionFilter) {
443
+ draft.toolOptions.data.baselineCorrection.zones =
444
+ baselineCorrectionFilter
445
+ ? baselineCorrectionFilter.value.zones
446
+ : [];
452
447
  }
453
448
  break;
454
449
  }
@@ -3,10 +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
- const { data, activeSpectrum, activeTab: nucleus } = draft;
10
+ const { data, view: { spectra: { activeTab: nucleus }, }, } = draft;
11
+ const activeSpectrum = getActiveSpectrum(draft);
10
12
  if (activeSpectrum?.id) {
11
13
  const { index } = activeSpectrum;
12
14
  const datum = data[index];
@@ -16,7 +18,8 @@ function handleChangeIntegralSum(draft, options) {
16
18
  }
17
19
  function addIntegral(draft, action) {
18
20
  const { startX, endX } = action;
19
- const { data, molecules, activeTab: nucleus, activeSpectrum } = draft;
21
+ const { data, molecules, view: { spectra: { activeTab: nucleus }, }, } = draft;
22
+ const activeSpectrum = getActiveSpectrum(draft);
20
23
  const [from, to] = getRange(draft, { startX, endX });
21
24
  if (activeSpectrum?.id) {
22
25
  const datum = data[activeSpectrum.index];
@@ -41,9 +44,10 @@ function addIntegral(draft, action) {
41
44
  }
42
45
  }
43
46
  function deleteIntegral(draft, action) {
44
- if (draft.activeSpectrum) {
47
+ const activeSpectrum = getActiveSpectrum(draft);
48
+ if (activeSpectrum) {
45
49
  const state = original(draft);
46
- const { index } = draft.activeSpectrum;
50
+ const { index } = activeSpectrum;
47
51
  const { integralID } = action;
48
52
  const datum = draft.data[index];
49
53
  if (integralID == null) {
@@ -57,10 +61,11 @@ function deleteIntegral(draft, action) {
57
61
  }
58
62
  }
59
63
  function changeIntegral(draft, action) {
64
+ const activeSpectrum = getActiveSpectrum(draft);
60
65
  const state = original(draft);
61
66
  const integral = action.payload.data;
62
- if (draft.activeSpectrum?.id) {
63
- const { index } = draft.activeSpectrum;
67
+ if (activeSpectrum?.id) {
68
+ const { index } = activeSpectrum;
64
69
  const originalDatum = state.data[index];
65
70
  const datum = draft.data[index];
66
71
  const { x, re } = originalDatum.data;
@@ -77,9 +82,10 @@ function changeIntegral(draft, action) {
77
82
  }
78
83
  }
79
84
  function handleChangeIntegralsRelativeValue(draft, action) {
85
+ const activeSpectrum = getActiveSpectrum(draft);
80
86
  const data = action.payload.data;
81
- if (draft.activeSpectrum?.id) {
82
- const { index } = draft.activeSpectrum;
87
+ if (activeSpectrum?.id) {
88
+ const { index } = activeSpectrum;
83
89
  changeIntegralsRelative(draft.data[index], data);
84
90
  }
85
91
  }
@@ -2,10 +2,7 @@ import { Draft } from 'immer';
2
2
  import { State } from '../Reducer';
3
3
  declare function setIsLoading(draft: Draft<State>, isLoading: boolean): void;
4
4
  declare function initiate(draft: Draft<State>, action: any): State;
5
- declare function loadJDFFile(draft: Draft<State>, actions: any): void;
6
5
  declare function loadJcampFile(draft: Draft<State>, actions: any): void;
7
6
  declare function handleLoadJsonFile(draft: Draft<State>, action: any): State;
8
- declare function handleLoadMOLFile(draft: Draft<State>, actions: any): void;
9
- declare function handleLoadZIPFile(draft: Draft<State>, action: any): void;
10
- declare function handleLoadNmredata(draft: Draft<State>, action: any): State;
11
- export { setIsLoading, initiate, loadJcampFile, loadJDFFile, handleLoadJsonFile, handleLoadNmredata, handleLoadMOLFile, handleLoadZIPFile, };
7
+ declare function loadDropFiles(draft: Draft<State>, actions: any): void;
8
+ export { setIsLoading, initiate, loadJcampFile, loadDropFiles, handleLoadJsonFile, };