nmrium 0.41.0 → 0.43.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 (247) hide show
  1. package/lib/component/1d/ApodizationLine.js +1 -1
  2. package/lib/component/1d/Chart1D.js +3 -2
  3. package/lib/component/1d/Line.js +1 -1
  4. package/lib/component/1d/Viewer1D.js +15 -3
  5. package/lib/component/1d/integral/IntegralResizable.js +4 -3
  6. package/lib/component/1d/multiAnalysis/AnalysisRange.js +3 -1
  7. package/lib/component/1d/peaks/PeakAnnotations.js +20 -25
  8. package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.d.ts +2 -0
  9. package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.js +59 -0
  10. package/lib/component/1d/peaks/PeakEditionManager.d.ts +18 -0
  11. package/lib/component/1d/peaks/PeakEditionManager.js +98 -0
  12. package/lib/component/1d/peaks/Peaks.d.ts +1 -0
  13. package/lib/component/1d/peaks/Peaks.js +22 -0
  14. package/lib/component/1d/ranges/Range.js +3 -1
  15. package/lib/component/1d/tool/BaseLineZones.d.ts +1 -1
  16. package/lib/component/1d/tool/BaseLineZones.js +11 -31
  17. package/lib/component/1d/utilities/intersectionResolver.d.ts +25 -0
  18. package/lib/component/1d/utilities/intersectionResolver.js +71 -0
  19. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +3 -2
  20. package/lib/component/1d-2d/components/SpectrumInfoBlock.js +4 -1
  21. package/lib/component/2d/SlicingView.js +1 -1
  22. package/lib/component/2d/ft/Contours.js +1 -1
  23. package/lib/component/EventsTrackers/KeysListenerTracker.d.ts +5 -1
  24. package/lib/component/EventsTrackers/KeysListenerTracker.js +47 -6
  25. package/lib/component/assignment/index.d.ts +6 -1
  26. package/lib/component/assignment/index.js +5 -1
  27. package/lib/component/context/DispatchContext.d.ts +1 -2
  28. package/lib/component/context/KeyModifierContext.d.ts +13 -0
  29. package/lib/component/context/KeyModifierContext.js +39 -0
  30. package/lib/component/context/PreferencesContext.d.ts +39 -39
  31. package/lib/component/elements/Button.js +2 -0
  32. package/lib/component/elements/Input.js +1 -0
  33. package/lib/component/elements/NumberInput.d.ts +1 -0
  34. package/lib/component/elements/NumberInput.js +10 -3
  35. package/lib/component/elements/Scroller.d.ts +15 -0
  36. package/lib/component/elements/Scroller.js +31 -0
  37. package/lib/component/elements/formik/FormikOnChange.js +1 -1
  38. package/lib/component/elements/popup/Modal/ConfirmDialog.js +1 -1
  39. package/lib/component/header/ApodizationOptionsPanel.js +23 -14
  40. package/lib/component/header/BaseLineCorrectionPanel.js +31 -10
  41. package/lib/component/header/Header.d.ts +10 -3
  42. package/lib/component/header/Header.js +5 -5
  43. package/lib/component/header/ZeroFillingOptionsPanel.js +37 -31
  44. package/lib/component/highlight/index.d.ts +1 -0
  45. package/lib/component/highlight/index.js +1 -0
  46. package/lib/component/hooks/useActiveSpectrumPeaksViewState.js +1 -0
  47. package/lib/component/hooks/useCheckToolsVisibility.js +7 -3
  48. package/lib/component/hooks/useResizerStatus.d.ts +2 -0
  49. package/lib/component/hooks/useResizerStatus.js +7 -0
  50. package/lib/component/hooks/useSaveSettings.js +9 -11
  51. package/lib/component/hooks/useSpectrum.js +1 -1
  52. package/lib/component/main/ErrorOverlay.js +20 -0
  53. package/lib/component/main/InnerNMRium.d.ts +7 -0
  54. package/lib/component/main/InnerNMRium.js +52 -0
  55. package/lib/component/main/InnerNMRiumContents.d.ts +14 -0
  56. package/lib/component/main/InnerNMRiumContents.js +89 -0
  57. package/lib/component/main/NMRium.d.ts +23 -0
  58. package/lib/component/main/NMRium.js +13 -0
  59. package/lib/component/main/NMRiumStateProvider.d.ts +9 -0
  60. package/lib/component/main/NMRiumStateProvider.js +74 -0
  61. package/lib/component/{SplitPaneWrapper.js → main/SplitPaneWrapper.js} +1 -1
  62. package/lib/component/main/StateError.d.ts +4 -0
  63. package/lib/component/main/StateError.js +16 -0
  64. package/lib/component/main/index.d.ts +3 -0
  65. package/lib/component/main/index.js +3 -0
  66. package/lib/component/main/types.d.ts +18 -0
  67. package/lib/component/main/types.js +2 -0
  68. package/lib/component/modal/AboutPredictionModal.js +1 -1
  69. package/lib/component/modal/AboutSpectrumSimulationModal.js +1 -1
  70. package/lib/component/modal/PredictSpectraModal.js +1 -1
  71. package/lib/component/modal/changeSum/ChangeSumModal.d.ts +5 -16
  72. package/lib/component/modal/changeSum/ChangeSumModal.js +6 -115
  73. package/lib/component/modal/changeSum/ChangeSumModalContents.d.ts +18 -0
  74. package/lib/component/modal/changeSum/ChangeSumModalContents.js +94 -0
  75. package/lib/component/modal/setting/GeneralSettings.js +2 -2
  76. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.d.ts +1 -1
  77. package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +9 -2
  78. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +6 -11
  79. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -6
  80. package/lib/component/panels/MoleculesPanel/Utilities.d.ts +3 -9
  81. package/lib/component/panels/MoleculesPanel/Utilities.js +14 -10
  82. package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts +3 -3
  83. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +4 -4
  84. package/lib/component/panels/PeaksPanel/PeaksPanel.js +11 -5
  85. package/lib/component/panels/RangesPanel/RangesHeader.js +6 -10
  86. package/lib/component/panels/SpectrumsPanel/SpectraPreferences.js +4 -3
  87. package/lib/component/panels/SpectrumsPanel/base/ShowHideSpectrumButton.js +1 -1
  88. package/lib/component/panels/SummaryPanel/SummaryPanel.js +4 -3
  89. package/lib/component/panels/ZonesPanel/ZonesPanel.js +3 -2
  90. package/lib/component/panels/ZonesPanel/ZonesPreferences.js +1 -1
  91. package/lib/component/panels/databasePanel/DatabasePanel.js +33 -26
  92. package/lib/component/panels/header/DefaultPanelHeader.d.ts +3 -4
  93. package/lib/component/panels/header/DefaultPanelHeader.js +9 -5
  94. package/lib/component/panels/predictionPanel/PredictionPanel.js +1 -1
  95. package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +0 -1
  96. package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +1 -1
  97. package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +1 -2
  98. package/lib/component/reducer/IgnoreActions.js +0 -1
  99. package/lib/component/reducer/Reducer.d.ts +1 -6
  100. package/lib/component/reducer/Reducer.js +32 -6
  101. package/lib/component/reducer/actions/FiltersActions.d.ts +32 -11
  102. package/lib/component/reducer/actions/FiltersActions.js +96 -28
  103. package/lib/component/reducer/actions/IntegralsActions.d.ts +6 -2
  104. package/lib/component/reducer/actions/IntegralsActions.js +44 -20
  105. package/lib/component/reducer/actions/MoleculeActions.d.ts +6 -2
  106. package/lib/component/reducer/actions/MoleculeActions.js +8 -2
  107. package/lib/component/reducer/actions/PeaksActions.d.ts +6 -4
  108. package/lib/component/reducer/actions/PeaksActions.js +19 -1
  109. package/lib/component/reducer/actions/RangesActions.d.ts +6 -2
  110. package/lib/component/reducer/actions/RangesActions.js +31 -3
  111. package/lib/component/reducer/preferences/actions/addWorkspace.js +19 -15
  112. package/lib/component/reducer/preferences/preferencesReducer.d.ts +1 -1
  113. package/lib/component/reducer/preferences/utilities/getPreferencesByWorkspace.d.ts +1 -1
  114. package/lib/component/toolbar/FunctionToolBar.js +13 -3
  115. package/lib/component/toolbar/ToolTypes.d.ts +1 -0
  116. package/lib/component/toolbar/ToolTypes.js +36 -0
  117. package/lib/component/utility/PathBuilder.js +11 -0
  118. package/lib/component/utility/export.js +7 -4
  119. package/lib/component/utility/filterType.d.ts +3 -0
  120. package/lib/component/utility/filterType.js +1 -0
  121. package/lib/component/workspaces/basic.js +2 -0
  122. package/lib/component/workspaces/embedded.js +2 -0
  123. package/lib/component/workspaces/exercise.js +2 -0
  124. package/lib/component/workspaces/prediction.js +9 -0
  125. package/lib/component/workspaces/process1D.js +2 -0
  126. package/lib/component/workspaces/workspaceDefaultProperties.js +10 -5
  127. package/lib/data/PredictionManager.d.ts +3 -3
  128. package/lib/data/PredictionManager.js +10 -10
  129. package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +1 -2
  130. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +2 -8
  131. package/lib/data/data1d/database.d.ts +4 -2
  132. package/lib/data/data1d/database.js +10 -3
  133. package/lib/data/molecules/Molecule.js +2 -2
  134. package/lib/data/molecules/MoleculeManager.d.ts +1 -0
  135. package/lib/data/molecules/MoleculeManager.js +14 -0
  136. package/lib/data/utilities/checkModifierKeyActivated.d.ts +1 -1
  137. package/lib/data/utilities/checkModifierKeyActivated.js +8 -13
  138. package/lib/versionInfo.js +1 -1
  139. package/lib-cjs/component/1d/ApodizationLine.js +1 -1
  140. package/lib-cjs/component/1d/Chart1D.js +3 -2
  141. package/lib-cjs/component/1d/Line.js +1 -1
  142. package/lib-cjs/component/1d/Viewer1D.js +15 -3
  143. package/lib-cjs/component/1d/integral/IntegralResizable.js +4 -3
  144. package/lib-cjs/component/1d/multiAnalysis/AnalysisRange.js +3 -1
  145. package/lib-cjs/component/1d/peaks/PeakAnnotations.js +19 -24
  146. package/lib-cjs/component/1d/peaks/PeakAnnotationsSpreadMode.js +64 -0
  147. package/lib-cjs/component/1d/peaks/PeakEditionManager.js +129 -0
  148. package/lib-cjs/component/1d/peaks/Peaks.js +29 -0
  149. package/lib-cjs/component/1d/ranges/Range.js +3 -1
  150. package/lib-cjs/component/1d/tool/BaseLineZones.js +11 -34
  151. package/lib-cjs/component/1d/utilities/intersectionResolver.js +75 -0
  152. package/lib-cjs/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +3 -2
  153. package/lib-cjs/component/1d-2d/components/SpectrumInfoBlock.js +4 -1
  154. package/lib-cjs/component/2d/SlicingView.js +1 -1
  155. package/lib-cjs/component/2d/ft/Contours.js +1 -1
  156. package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +46 -5
  157. package/lib-cjs/component/assignment/index.js +5 -1
  158. package/lib-cjs/component/context/KeyModifierContext.js +44 -0
  159. package/lib-cjs/component/elements/Button.js +2 -0
  160. package/lib-cjs/component/elements/Input.js +1 -0
  161. package/lib-cjs/component/elements/NumberInput.js +12 -2
  162. package/lib-cjs/component/elements/Scroller.js +35 -0
  163. package/lib-cjs/component/elements/formik/FormikOnChange.js +1 -1
  164. package/lib-cjs/component/elements/popup/Modal/ConfirmDialog.js +1 -1
  165. package/lib-cjs/component/header/ApodizationOptionsPanel.js +23 -14
  166. package/lib-cjs/component/header/BaseLineCorrectionPanel.js +30 -9
  167. package/lib-cjs/component/header/Header.js +5 -5
  168. package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +35 -29
  169. package/lib-cjs/component/highlight/index.js +1 -0
  170. package/lib-cjs/component/hooks/useActiveSpectrumPeaksViewState.js +1 -0
  171. package/lib-cjs/component/hooks/useCheckToolsVisibility.js +7 -3
  172. package/lib-cjs/component/hooks/useResizerStatus.js +11 -0
  173. package/lib-cjs/component/hooks/useSaveSettings.js +9 -11
  174. package/lib-cjs/component/hooks/useSpectrum.js +1 -1
  175. package/lib-cjs/component/main/ErrorOverlay.js +26 -0
  176. package/lib-cjs/component/main/InnerNMRium.js +82 -0
  177. package/lib-cjs/component/main/InnerNMRiumContents.js +96 -0
  178. package/lib-cjs/component/main/NMRium.js +19 -0
  179. package/lib-cjs/component/main/NMRiumStateProvider.js +80 -0
  180. package/lib-cjs/component/{SplitPaneWrapper.js → main/SplitPaneWrapper.js} +1 -1
  181. package/lib-cjs/component/main/StateError.js +20 -0
  182. package/lib-cjs/component/main/index.js +21 -0
  183. package/lib-cjs/component/main/types.js +3 -0
  184. package/lib-cjs/component/modal/AboutPredictionModal.js +1 -1
  185. package/lib-cjs/component/modal/AboutSpectrumSimulationModal.js +1 -1
  186. package/lib-cjs/component/modal/PredictSpectraModal.js +1 -1
  187. package/lib-cjs/component/modal/changeSum/ChangeSumModal.js +6 -141
  188. package/lib-cjs/component/modal/changeSum/ChangeSumModalContents.js +124 -0
  189. package/lib-cjs/component/modal/setting/GeneralSettings.js +2 -2
  190. package/lib-cjs/component/modal/setting/settings-tabs/InfoBlockTabContent.js +9 -2
  191. package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +29 -11
  192. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -6
  193. package/lib-cjs/component/panels/MoleculesPanel/Utilities.js +14 -10
  194. package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +4 -4
  195. package/lib-cjs/component/panels/PeaksPanel/PeaksPanel.js +32 -3
  196. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +29 -10
  197. package/lib-cjs/component/panels/SpectrumsPanel/SpectraPreferences.js +3 -2
  198. package/lib-cjs/component/panels/SpectrumsPanel/base/ShowHideSpectrumButton.js +1 -1
  199. package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +27 -3
  200. package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +26 -2
  201. package/lib-cjs/component/panels/ZonesPanel/ZonesPreferences.js +1 -1
  202. package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +33 -26
  203. package/lib-cjs/component/panels/header/DefaultPanelHeader.js +11 -5
  204. package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +1 -1
  205. package/lib-cjs/component/panels/predictionPanel/PredictionSimpleOptions.js +0 -1
  206. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulation.js +1 -1
  207. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +1 -2
  208. package/lib-cjs/component/reducer/IgnoreActions.js +0 -1
  209. package/lib-cjs/component/reducer/Reducer.js +31 -5
  210. package/lib-cjs/component/reducer/actions/FiltersActions.js +98 -28
  211. package/lib-cjs/component/reducer/actions/IntegralsActions.js +45 -20
  212. package/lib-cjs/component/reducer/actions/MoleculeActions.js +9 -2
  213. package/lib-cjs/component/reducer/actions/PeaksActions.js +20 -1
  214. package/lib-cjs/component/reducer/actions/RangesActions.js +31 -2
  215. package/lib-cjs/component/reducer/preferences/actions/addWorkspace.js +19 -15
  216. package/lib-cjs/component/toolbar/FunctionToolBar.js +13 -3
  217. package/lib-cjs/component/toolbar/ToolTypes.js +36 -0
  218. package/lib-cjs/component/utility/PathBuilder.js +11 -0
  219. package/lib-cjs/component/utility/export.js +7 -4
  220. package/lib-cjs/component/utility/filterType.js +2 -0
  221. package/lib-cjs/component/workspaces/basic.js +2 -0
  222. package/lib-cjs/component/workspaces/embedded.js +2 -0
  223. package/lib-cjs/component/workspaces/exercise.js +2 -0
  224. package/lib-cjs/component/workspaces/prediction.js +9 -0
  225. package/lib-cjs/component/workspaces/process1D.js +2 -0
  226. package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +10 -5
  227. package/lib-cjs/data/PredictionManager.js +9 -9
  228. package/lib-cjs/data/data1d/Spectrum1D/ranges/addRange.js +1 -7
  229. package/lib-cjs/data/data1d/database.js +10 -3
  230. package/lib-cjs/data/molecules/Molecule.js +2 -2
  231. package/lib-cjs/data/molecules/MoleculeManager.js +16 -1
  232. package/lib-cjs/data/utilities/checkModifierKeyActivated.js +8 -13
  233. package/lib-cjs/versionInfo.js +1 -1
  234. package/package.json +26 -25
  235. package/lib/component/1d/peaks/PeakAnnotation.d.ts +0 -12
  236. package/lib/component/1d/peaks/PeakAnnotation.js +0 -116
  237. package/lib/component/ErrorOverlay.js +0 -27
  238. package/lib/component/NMRium.d.ts +0 -42
  239. package/lib/component/NMRium.js +0 -237
  240. package/lib/component/reducer/actions/GlobalActions.d.ts +0 -9
  241. package/lib/component/reducer/actions/GlobalActions.js +0 -4
  242. package/lib-cjs/component/1d/peaks/PeakAnnotation.js +0 -118
  243. package/lib-cjs/component/ErrorOverlay.js +0 -30
  244. package/lib-cjs/component/NMRium.js +0 -267
  245. package/lib-cjs/component/reducer/actions/GlobalActions.js +0 -7
  246. /package/lib/component/{ErrorOverlay.d.ts → main/ErrorOverlay.d.ts} +0 -0
  247. /package/lib/component/{SplitPaneWrapper.d.ts → main/SplitPaneWrapper.d.ts} +0 -0
@@ -13,7 +13,7 @@ import { getStrongestPeak } from '../helper/getStrongestPeak';
13
13
  import { setDomain, setMode } from './DomainActions';
14
14
  import { changeSpectrumVerticalAlignment } from './PreferencesActions';
15
15
  import { activateTool, resetSelectedTool } from './ToolsActions';
16
- const { fft, apodization, baselineCorrection, phaseCorrection, zeroFilling, shiftX, shift2DX, shift2DY, exclusionZones, signalProcessing, } = Filters;
16
+ const { fft, fftDimension1, fftDimension2, apodization, baselineCorrection, phaseCorrection, zeroFilling, shiftX, shift2DX, shift2DY, exclusionZones, signalProcessing, } = Filters;
17
17
  function getFilterUpdateDomainRules(filterName) {
18
18
  return (Filters[filterName]?.DOMAIN_UPDATE_RULES || {
19
19
  updateXDomain: false,
@@ -158,6 +158,25 @@ function updateView(draft, filterUpdateDomainRules) {
158
158
  setMode(draft);
159
159
  changeSpectrumVerticalAlignment(draft, { verticalAlign: 'auto-check' });
160
160
  }
161
+ function disableLivePreview(draft, id) {
162
+ const activeSpectrum = getActiveSpectrum(draft);
163
+ if (activeSpectrum) {
164
+ const index = activeSpectrum.index;
165
+ const { data } = draft.tempData[index];
166
+ draft.data[index].data = data;
167
+ setDomain(draft);
168
+ // reset default options
169
+ switch (id) {
170
+ case apodization.name: {
171
+ draft.toolOptions.data.apodizationOptions = defaultApodizationOptions;
172
+ break;
173
+ }
174
+ default: {
175
+ return null;
176
+ }
177
+ }
178
+ }
179
+ }
161
180
  //action
162
181
  function handleShiftSpectrumAlongXAxis(draft, action) {
163
182
  //apply filter into the spectrum
@@ -190,7 +209,7 @@ function handleApplyZeroFillingFilter(draft, action) {
190
209
  const filters = [
191
210
  {
192
211
  name: zeroFilling.id,
193
- value: action.payload,
212
+ value: action.payload.options,
194
213
  },
195
214
  ];
196
215
  FiltersManager.applyFilter(draft.data[index], filters, {
@@ -212,16 +231,22 @@ function handleApplyZeroFillingFilter(draft, action) {
212
231
  function handleCalculateZeroFillingFilter(draft, action) {
213
232
  const activeSpectrum = getActiveSpectrum(draft);
214
233
  if (activeSpectrum) {
215
- const index = activeSpectrum.index;
216
- const { data: { x, re, im }, filters, info, } = draft.tempData[index];
217
- const _data = { data: { x, re, im }, filters, info };
218
- zeroFilling.apply(_data, action.payload);
219
- const { im: newIm, re: newRe, x: newX } = _data.data;
220
- const datum = draft.data[index];
221
- datum.data.x = newX;
222
- datum.data.im = newIm;
223
- datum.data.re = newRe;
224
- draft.xDomain = [newX[0], newX.at(-1)];
234
+ const { options, livePreview } = action.payload;
235
+ if (livePreview) {
236
+ const index = activeSpectrum.index;
237
+ const { data: { x, re, im }, filters, info, } = draft.tempData[index];
238
+ const _data = { data: { x, re, im }, filters, info };
239
+ zeroFilling.apply(_data, options);
240
+ const { im: newIm, re: newRe, x: newX } = _data.data;
241
+ const datum = draft.data[index];
242
+ datum.data.x = newX;
243
+ datum.data.im = newIm;
244
+ datum.data.re = newRe;
245
+ draft.xDomain = [newX[0], newX.at(-1)];
246
+ }
247
+ else {
248
+ disableLivePreview(draft, zeroFilling.name);
249
+ }
225
250
  }
226
251
  }
227
252
  //action
@@ -229,15 +254,20 @@ function handleCalculateApodizationFilter(draft, action) {
229
254
  const activeSpectrum = getActiveSpectrum(draft);
230
255
  if (activeSpectrum) {
231
256
  const index = activeSpectrum.index;
232
- const options = action.payload;
233
- const { data: { x, re, im }, info, } = draft.tempData[index];
234
- const _data = { data: { x, re, im }, info };
235
- draft.toolOptions.data.apodizationOptions = options;
236
- apodization.apply(_data, options);
237
- const { im: newIm, re: newRe } = _data.data;
238
- const datum = draft.data[index];
239
- datum.data.im = newIm;
240
- datum.data.re = newRe;
257
+ const { livePreview, options } = action.payload;
258
+ if (livePreview) {
259
+ const { data: { x, re, im }, info, } = draft.tempData[index];
260
+ const _data = { data: { x, re, im }, info };
261
+ draft.toolOptions.data.apodizationOptions = options;
262
+ apodization.apply(_data, options);
263
+ const { im: newIm, re: newRe } = _data.data;
264
+ const datum = draft.data[index];
265
+ datum.data.im = newIm;
266
+ datum.data.re = newRe;
267
+ }
268
+ else {
269
+ disableLivePreview(draft, apodization.name);
270
+ }
241
271
  }
242
272
  }
243
273
  //action
@@ -249,7 +279,7 @@ function handleApplyApodizationFilter(draft, action) {
249
279
  FiltersManager.applyFilter(draft.data[index], [
250
280
  {
251
281
  name: apodization.id,
252
- value: action.payload,
282
+ value: action.payload.options,
253
283
  },
254
284
  ], { filterIndex: activeFilterIndex });
255
285
  if (activeFilterIndex !== -1) {
@@ -283,6 +313,42 @@ function handleApplyFFTFilter(draft) {
283
313
  }
284
314
  }
285
315
  }
316
+ function handleApplyFFtDimension1Filter(draft) {
317
+ const activeSpectrum = getActiveSpectrum(draft);
318
+ if (activeSpectrum) {
319
+ const { index } = activeSpectrum;
320
+ const activeFilterIndex = getActiveFilterIndex(draft);
321
+ //apply filter into the spectrum
322
+ FiltersManager.applyFilter(draft.data[index], [{ name: fftDimension1.id, value: {} }], { filterIndex: activeFilterIndex });
323
+ if (activeFilterIndex !== -1) {
324
+ rollbackSpectrumByFilter(draft, {
325
+ searchBy: 'name',
326
+ key: fftDimension1.id,
327
+ });
328
+ }
329
+ else {
330
+ updateView(draft, fftDimension1.DOMAIN_UPDATE_RULES);
331
+ }
332
+ }
333
+ }
334
+ function handleApplyFFtDimension2Filter(draft) {
335
+ const activeSpectrum = getActiveSpectrum(draft);
336
+ if (activeSpectrum) {
337
+ const { index } = activeSpectrum;
338
+ const activeFilterIndex = getActiveFilterIndex(draft);
339
+ //apply filter into the spectrum
340
+ FiltersManager.applyFilter(draft.data[index], [{ name: fftDimension2.id, value: {} }], { filterIndex: activeFilterIndex });
341
+ if (activeFilterIndex !== -1) {
342
+ rollbackSpectrumByFilter(draft, {
343
+ searchBy: 'name',
344
+ key: fftDimension2.id,
345
+ });
346
+ }
347
+ else {
348
+ updateView(draft, fftDimension2.DOMAIN_UPDATE_RULES);
349
+ }
350
+ }
351
+ }
286
352
  //action
287
353
  function handleApplyManualPhaseCorrectionFilter(draft, action) {
288
354
  const activeSpectrum = getActiveSpectrum(draft);
@@ -377,7 +443,7 @@ function handleBaseLineCorrectionFilter(draft, action) {
377
443
  const activeSpectrum = getActiveSpectrum(draft);
378
444
  if (activeSpectrum) {
379
445
  const { zones } = draft.toolOptions.data.baselineCorrection;
380
- const { livePreview, ...options } = action.payload;
446
+ const { options } = action.payload;
381
447
  const activeFilterIndex = getActiveFilterIndex(draft);
382
448
  FiltersManager.applyFilter(draft.data[activeSpectrum.index], [
383
449
  {
@@ -408,21 +474,23 @@ function calculateBaseLineCorrection(draft, baseLineOptions) {
408
474
  // save the baseline options temporary
409
475
  draft.toolOptions.data.baselineCorrection = {
410
476
  ...draft.toolOptions.data.baselineCorrection,
411
- ...(baseLineOptions ? { options: baseLineOptions } : {}),
477
+ ...(baseLineOptions && baseLineOptions),
412
478
  };
413
- const { zones, options } = draft.toolOptions.data.baselineCorrection;
414
- const { livePreview, ...filterOptions } = options;
479
+ const { zones, options, livePreview } = draft.toolOptions.data.baselineCorrection;
415
480
  if (livePreview) {
416
481
  const _data = { data: { x, re, im }, info };
417
482
  baselineCorrection.apply(_data, {
418
483
  zones,
419
- ...filterOptions,
484
+ ...options,
420
485
  });
421
486
  const { im: newIm, re: newRe } = _data.data;
422
487
  const datum = draft.data[index];
423
488
  datum.data.im = newIm;
424
489
  datum.data.re = newRe;
425
490
  }
491
+ else {
492
+ disableLivePreview(draft, baselineCorrection.id);
493
+ }
426
494
  }
427
495
  }
428
496
  //action
@@ -567,4 +635,4 @@ function handleDeleteExclusionZone(draft, action) {
567
635
  }
568
636
  }
569
637
  }
570
- export { handleShiftSpectrumAlongXAxis, handleApplyZeroFillingFilter, handleApplyApodizationFilter, handleApplyFFTFilter, handleApplyManualPhaseCorrectionFilter, handleApplyAutoPhaseCorrectionFilter, handleApplyAbsoluteFilter, handleCalculateManualPhaseCorrection, calculateBaseLineCorrection, handleCalculateBaseLineCorrection, handleCalculateApodizationFilter, handleCalculateZeroFillingFilter, handleEnableFilter, handleDeleteFilter, handleDeleteSpectraFilter, handleBaseLineCorrectionFilter, handleSetFilterSnapshotHandler, handleAddExclusionZone, handleDeleteExclusionZone, handleSignalProcessingFilter, rollbackSpectrum, rollbackSpectrumByFilter, };
638
+ export { handleShiftSpectrumAlongXAxis, handleApplyZeroFillingFilter, handleApplyApodizationFilter, handleApplyFFTFilter, handleApplyFFtDimension1Filter, handleApplyFFtDimension2Filter, handleApplyManualPhaseCorrectionFilter, handleApplyAutoPhaseCorrectionFilter, handleApplyAbsoluteFilter, handleCalculateManualPhaseCorrection, calculateBaseLineCorrection, handleCalculateBaseLineCorrection, handleCalculateApodizationFilter, handleCalculateZeroFillingFilter, handleEnableFilter, handleDeleteFilter, handleDeleteSpectraFilter, handleBaseLineCorrectionFilter, handleSetFilterSnapshotHandler, handleAddExclusionZone, handleDeleteExclusionZone, handleSignalProcessingFilter, rollbackSpectrum, rollbackSpectrumByFilter, };
@@ -20,11 +20,15 @@ type ChangeIntegralRelativeValueAction = ActionType<'CHANGE_INTEGRAL_RELATIVE',
20
20
  id: string;
21
21
  value: number;
22
22
  }>;
23
- export type IntegralsActions = ChangeIntegralSumAction | AddIntegralAction | DeleteIntegralAction | ChangeIntegralAction | ChangeIntegralRelativeValueAction | ActionType<'CHANGE_INTEGRALS_SUM_FLAG'>;
23
+ type CutIntegralAction = ActionType<'CUT_INTEGRAL', {
24
+ cutValue: number;
25
+ }>;
26
+ export type IntegralsActions = ChangeIntegralSumAction | AddIntegralAction | DeleteIntegralAction | ChangeIntegralAction | ChangeIntegralRelativeValueAction | CutIntegralAction | ActionType<'CHANGE_INTEGRALS_SUM_FLAG'>;
24
27
  declare function handleChangeIntegralSum(draft: Draft<State>, action: ChangeIntegralSumAction): void;
25
28
  declare function handleAddIntegral(draft: Draft<State>, action: AddIntegralAction): void;
26
29
  declare function handleDeleteIntegral(draft: Draft<State>, action: DeleteIntegralAction): void;
27
30
  declare function handleChangeIntegral(draft: Draft<State>, action: ChangeIntegralAction): void;
28
31
  declare function handleChangeIntegralsRelativeValue(draft: Draft<State>, action: ChangeIntegralRelativeValueAction): void;
29
32
  declare function handleChangeIntegralsSumFlag(draft: any): void;
30
- export { handleChangeIntegralSum, handleAddIntegral, handleDeleteIntegral, handleChangeIntegral, handleChangeIntegralsRelativeValue, handleChangeIntegralsSumFlag, };
33
+ declare function handleCutIntegral(draft: Draft<State>, action: CutIntegralAction): void;
34
+ export { handleCutIntegral, handleChangeIntegralSum, handleAddIntegral, handleDeleteIntegral, handleChangeIntegral, handleChangeIntegralsRelativeValue, handleChangeIntegralsSumFlag, };
@@ -5,6 +5,7 @@ import { updateIntegralsRelativeValues, changeIntegralsRelative, getShiftX, } fr
5
5
  import { initSumOptions, setSumOptions, } from '../../../data/data1d/Spectrum1D/SumManager';
6
6
  import { getActiveSpectrum } from '../helper/getActiveSpectrum';
7
7
  import getRange from '../helper/getRange';
8
+ import { getSpectrum } from '../helper/getSpectrum';
8
9
  import { setIntegralsYDomain } from './DomainActions';
9
10
  function handleChangeIntegralSum(draft, action) {
10
11
  const { options } = action.payload;
@@ -17,31 +18,39 @@ function handleChangeIntegralSum(draft, action) {
17
18
  updateIntegralsRelativeValues(datum, true);
18
19
  }
19
20
  }
21
+ function initiateIntergalSumOptions(datum, options) {
22
+ const { molecules, nucleus } = options;
23
+ datum.integrals.options = initSumOptions(datum.integrals.options, {
24
+ molecules,
25
+ nucleus,
26
+ });
27
+ }
28
+ function addIntegral(datum, options) {
29
+ const { from, to } = options;
30
+ const { x, re } = datum.data;
31
+ const shiftX = getShiftX(datum);
32
+ const integration = xyIntegration({ x, y: re }, { from, to, reverse: true });
33
+ const integral = {
34
+ id: v4(),
35
+ originFrom: from - shiftX,
36
+ originTo: to - shiftX,
37
+ from,
38
+ to,
39
+ integral: integration,
40
+ absolute: integration,
41
+ kind: 'signal',
42
+ };
43
+ datum.integrals.values.push(integral);
44
+ }
20
45
  function handleAddIntegral(draft, action) {
21
46
  const { startX, endX } = action.payload;
22
47
  const { data, molecules, view: { spectra: { activeTab: nucleus }, }, } = draft;
23
48
  const activeSpectrum = getActiveSpectrum(draft);
24
- const [from, to] = getRange(draft, { startX, endX });
25
49
  if (activeSpectrum?.id) {
50
+ const [from, to] = getRange(draft, { startX, endX });
26
51
  const datum = data[activeSpectrum.index];
27
- const { x, re } = datum.data;
28
- const shiftX = getShiftX(datum);
29
- const integration = xyIntegration({ x, y: re }, { from, to, reverse: true });
30
- const integral = {
31
- id: v4(),
32
- originFrom: from - shiftX,
33
- originTo: to - shiftX,
34
- from,
35
- to,
36
- integral: integration,
37
- absolute: integration,
38
- kind: 'signal',
39
- };
40
- datum.integrals.values.push(integral);
41
- datum.integrals.options = initSumOptions(datum.integrals.options, {
42
- molecules,
43
- nucleus,
44
- });
52
+ addIntegral(datum, { from, to });
53
+ initiateIntergalSumOptions(datum, { molecules, nucleus });
45
54
  updateIntegralsRelativeValues(datum);
46
55
  setIntegralsYDomain(draft, datum);
47
56
  }
@@ -100,4 +109,19 @@ function handleChangeIntegralsSumFlag(draft) {
100
109
  integralOptions.isSumConstant = !integralOptions.isSumConstant;
101
110
  }
102
111
  }
103
- export { handleChangeIntegralSum, handleAddIntegral, handleDeleteIntegral, handleChangeIntegral, handleChangeIntegralsRelativeValue, handleChangeIntegralsSumFlag, };
112
+ function handleCutIntegral(draft, action) {
113
+ const { cutValue } = action.payload;
114
+ const spectrum = getSpectrum(draft);
115
+ const integrals = spectrum.integrals.values;
116
+ for (let i = 0; i < integrals.length; i++) {
117
+ const { to, from } = integrals[i];
118
+ if (cutValue > from && cutValue < to) {
119
+ integrals.splice(i, 1);
120
+ addIntegral(spectrum, { from, to: cutValue });
121
+ addIntegral(spectrum, { from: cutValue, to });
122
+ }
123
+ }
124
+ updateIntegralsRelativeValues(spectrum);
125
+ setIntegralsYDomain(draft, spectrum);
126
+ }
127
+ export { handleCutIntegral, handleChangeIntegralSum, handleAddIntegral, handleDeleteIntegral, handleChangeIntegral, handleChangeIntegralsRelativeValue, handleChangeIntegralsSumFlag, };
@@ -10,6 +10,9 @@ interface AddMoleculeProps {
10
10
  floatMoleculeOnSave?: boolean;
11
11
  }
12
12
  type AddMoleculeAction = ActionType<'ADD_MOLECULE', AddMoleculeProps>;
13
+ type AddMoleculesAction = ActionType<'ADD_MOLECULES', {
14
+ molecules: StateMolecule[];
15
+ }>;
13
16
  type SetMoleculeAction = ActionType<'SET_MOLECULE', Required<StateMolecule>>;
14
17
  type DeleteMoleculeAction = ActionType<'DELETE_MOLECULE', {
15
18
  id: string;
@@ -33,8 +36,9 @@ type ChangeMoleculeLabelAction = ActionType<'CHANGE_MOLECULE_LABEL', {
33
36
  id: string;
34
37
  label: string;
35
38
  }>;
36
- export type MoleculeActions = AddMoleculeAction | SetMoleculeAction | DeleteMoleculeAction | PredictSpectraFromMoleculeAction | ToggleMoleculeViewObjectAction | ChangeFloatMoleculePositionAction | ChangeMoleculeLabelAction;
39
+ export type MoleculeActions = AddMoleculeAction | AddMoleculesAction | SetMoleculeAction | DeleteMoleculeAction | PredictSpectraFromMoleculeAction | ToggleMoleculeViewObjectAction | ChangeFloatMoleculePositionAction | ChangeMoleculeLabelAction;
37
40
  declare function handleAddMolecule(draft: Draft<State>, action: AddMoleculeAction): void;
41
+ declare function handleAddMolecules(draft: Draft<State>, action: AddMoleculesAction): void;
38
42
  declare function handleSetMolecule(draft: Draft<State>, action: SetMoleculeAction): void;
39
43
  declare function handleDeleteMolecule(draft: Draft<State>, action: DeleteMoleculeAction): void;
40
44
  declare function handlePredictSpectraFromMolecule(draft: Draft<State>, action: PredictSpectraFromMoleculeAction): void;
@@ -42,4 +46,4 @@ declare function handleFloatMoleculeOverSpectrum(draft: Draft<State>, action: To
42
46
  declare function handleToggleMoleculeAtomsNumbers(draft: Draft<State>, action: ToggleMoleculeViewObjectAction): void;
43
47
  declare function handleChangeFloatMoleculePosition(draft: Draft<State>, action: ChangeFloatMoleculePositionAction): void;
44
48
  declare function handleChangeMoleculeLabel(draft: Draft<State>, action: ChangeMoleculeLabelAction): void;
45
- export { handleAddMolecule, handleSetMolecule, handleDeleteMolecule, handlePredictSpectraFromMolecule, handleFloatMoleculeOverSpectrum, handleToggleMoleculeAtomsNumbers, handleChangeFloatMoleculePosition, handleChangeMoleculeLabel, };
49
+ export { handleAddMolecule, handleAddMolecules, handleSetMolecule, handleDeleteMolecule, handlePredictSpectraFromMolecule, handleFloatMoleculeOverSpectrum, handleToggleMoleculeAtomsNumbers, handleChangeFloatMoleculePosition, handleChangeMoleculeLabel, };
@@ -31,6 +31,12 @@ function addMolecule(draft, props) {
31
31
  function handleAddMolecule(draft, action) {
32
32
  addMolecule(draft, action.payload);
33
33
  }
34
+ function handleAddMolecules(draft, action) {
35
+ const molecules = action.payload.molecules;
36
+ for (const { molfile } of molecules) {
37
+ addMolecule(draft, { molfile });
38
+ }
39
+ }
34
40
  function setMolecule(draft, props) {
35
41
  const { id, label, molfile } = props;
36
42
  MoleculeManager.setMolfile(draft.molecules, {
@@ -107,7 +113,7 @@ function checkPredictions(predictedSpectra, inputOptions, molfile, logger) {
107
113
  const { spectra } = inputOptions;
108
114
  const missing2DPrediction = [];
109
115
  const molecule = OCL.Molecule.fromMolfile(molfile);
110
- molecule.addImplicitHydrogens();
116
+ //@ts-expect-error Will be fixed once OCL-utils is typed correctly
111
117
  const { atoms } = getAtoms(molecule);
112
118
  for (const [experiment, required] of Object.entries(spectra)) {
113
119
  if (!required || predictedSpectra[experiment])
@@ -236,4 +242,4 @@ function handleChangeMoleculeLabel(draft, action) {
236
242
  const moleculeIndex = draft.molecules.findIndex((molecule) => molecule.id === id);
237
243
  draft.molecules[moleculeIndex].label = label;
238
244
  }
239
- export { handleAddMolecule, handleSetMolecule, handleDeleteMolecule, handlePredictSpectraFromMolecule, handleFloatMoleculeOverSpectrum, handleToggleMoleculeAtomsNumbers, handleChangeFloatMoleculePosition, handleChangeMoleculeLabel, };
245
+ export { handleAddMolecule, handleAddMolecules, handleSetMolecule, handleDeleteMolecule, handlePredictSpectraFromMolecule, handleFloatMoleculeOverSpectrum, handleToggleMoleculeAtomsNumbers, handleChangeFloatMoleculePosition, handleChangeMoleculeLabel, };
@@ -1,6 +1,7 @@
1
1
  import { Draft } from 'immer';
2
+ import { PeaksViewState } from 'nmr-load-save';
2
3
  import { Peak1D, OptionsXYAutoPeaksPicking } from 'nmr-processing';
3
- import { defaultPeaksViewState } from '../../hooks/useActiveSpectrumPeaksViewState';
4
+ import { FilterType } from '../../utility/filterType';
4
5
  import { State } from '../Reducer';
5
6
  import { ActionType } from '../types/ActionType';
6
7
  type AddPeakAction = ActionType<'ADD_PEAK', {
@@ -27,9 +28,9 @@ type ChangePeaksShapeAction = ActionType<'CHANGE_PEAK_SHAPE', {
27
28
  shape: Peak1D['shape'];
28
29
  }>;
29
30
  type TogglePeaksViewAction = ActionType<'TOGGLE_PEAKS_VIEW_PROPERTY', {
30
- key: keyof typeof defaultPeaksViewState;
31
+ key: keyof FilterType<PeaksViewState, boolean>;
31
32
  }>;
32
- export type PeaksActions = AddPeakAction | AddPeaksAction | DeletePeakAction | OptimizePeaksAction | AutoPeaksPickingAction | ChangePeaksShapeAction | TogglePeaksViewAction;
33
+ export type PeaksActions = AddPeakAction | AddPeaksAction | DeletePeakAction | OptimizePeaksAction | AutoPeaksPickingAction | ChangePeaksShapeAction | TogglePeaksViewAction | ActionType<'TOGGLE_PEAKS_DISPLAYING_MODE'>;
33
34
  declare function handleAddPeak(draft: Draft<State>, action: AddPeakAction): void;
34
35
  declare function handleAddPeaks(draft: Draft<State>, action: AddPeaksAction): void;
35
36
  declare function handleDeletePeak(draft: Draft<State>, action: DeletePeakAction): void;
@@ -37,4 +38,5 @@ declare function handleOptimizePeaks(draft: Draft<State>, action: OptimizePeaksA
37
38
  declare function handleAutoPeakPicking(draft: Draft<State>, action: AutoPeaksPickingAction): void;
38
39
  declare function handleChangePeakShape(draft: Draft<State>, action: ChangePeaksShapeAction): void;
39
40
  declare function handleTogglePeaksViewProperty(draft: Draft<State>, action: TogglePeaksViewAction): void;
40
- export { handleAddPeak, handleAddPeaks, handleDeletePeak, handleAutoPeakPicking, handleOptimizePeaks, handleChangePeakShape, handleTogglePeaksViewProperty, };
41
+ declare function handleChangePeaksDisplayingMode(draft: Draft<State>): void;
42
+ export { handleAddPeak, handleAddPeaks, handleDeletePeak, handleAutoPeakPicking, handleOptimizePeaks, handleChangePeakShape, handleTogglePeaksViewProperty, handleChangePeaksDisplayingMode, };
@@ -145,4 +145,22 @@ function togglePeaksViewProperty(draft, key) {
145
145
  }
146
146
  }
147
147
  }
148
- export { handleAddPeak, handleAddPeaks, handleDeletePeak, handleAutoPeakPicking, handleOptimizePeaks, handleChangePeakShape, handleTogglePeaksViewProperty, };
148
+ function handleChangePeaksDisplayingMode(draft) {
149
+ const activeSpectrum = getActiveSpectrum(draft);
150
+ if (activeSpectrum?.id) {
151
+ const peaksView = draft.view.peaks;
152
+ if (peaksView[activeSpectrum.id]) {
153
+ peaksView[activeSpectrum.id].displayingMode =
154
+ peaksView[activeSpectrum.id].displayingMode === 'single'
155
+ ? 'spread'
156
+ : 'single';
157
+ }
158
+ else {
159
+ const defaultPeaksView = { ...defaultPeaksViewState };
160
+ defaultPeaksView.displayingMode =
161
+ defaultPeaksView.displayingMode === 'single' ? 'spread' : 'single';
162
+ peaksView[activeSpectrum.id] = defaultPeaksView;
163
+ }
164
+ }
165
+ }
166
+ export { handleAddPeak, handleAddPeaks, handleDeletePeak, handleAutoPeakPicking, handleOptimizePeaks, handleChangePeakShape, handleTogglePeaksViewProperty, handleChangePeaksDisplayingMode, };
@@ -63,7 +63,10 @@ type UpdateRangAction = ActionType<'UPDATE_RANGE', {
63
63
  type ToggleAction = ActionType<'SHOW_MULTIPLICITY_TREES' | 'SHOW_RANGES_INTEGRALS' | 'SHOW_J_GRAPH', {
64
64
  id: string;
65
65
  }>;
66
- export type RangesActions = AutoRangesDetectionAction | DeleteRangeAction | ChangeRangeSignalKindAction | SaveEditedRangeAction | DeleteSignalAction | UnlinkRangeAction | SetDiaIDRangeAction | ResizeRangeAction | ChangeRangeSumAction | AddRangeAction | ChangeRangeRelativeValueAction | ChangeRangeSignalValueAction | UpdateRangAction | ToggleAction | ActionType<'AUTO_RANGES_SPECTRA_PICKING' | 'CHANGE_RANGES_SUM_FLAG'>;
66
+ type CutRangAction = ActionType<'CUT_RANGE', {
67
+ cutValue: number;
68
+ }>;
69
+ export type RangesActions = AutoRangesDetectionAction | DeleteRangeAction | ChangeRangeSignalKindAction | SaveEditedRangeAction | DeleteSignalAction | UnlinkRangeAction | SetDiaIDRangeAction | ResizeRangeAction | ChangeRangeSumAction | AddRangeAction | ChangeRangeRelativeValueAction | ChangeRangeSignalValueAction | UpdateRangAction | ToggleAction | CutRangAction | ActionType<'AUTO_RANGES_SPECTRA_PICKING' | 'CHANGE_RANGES_SUM_FLAG'>;
67
70
  declare function handleAutoRangesDetection(draft: Draft<State>, action: AutoRangesDetectionAction): void;
68
71
  declare function handleAutoSpectraRangesDetection(draft: Draft<State>): void;
69
72
  declare function handleDeleteRange(draft: Draft<State>, action: DeleteRangeAction): void;
@@ -84,4 +87,5 @@ declare function handleUpdateRange(draft: Draft<State>, action: UpdateRangAction
84
87
  declare function handleShowMultiplicityTrees(draft: Draft<State>, action: ToggleAction): void;
85
88
  declare function handleShowRangesIntegrals(draft: Draft<State>, action: ToggleAction): void;
86
89
  declare function handleShowJGraph(draft: Draft<State>, action: ToggleAction): void;
87
- export { handleAutoRangesDetection, handleDeleteRange, deleteSignal1D, handleDeleteSignal, handleChangeRangeSum, handleAddRange, handleResizeRange, handleChangeRangeRelativeValue, handleChangeRangeSignalValue, handleChangeRangeSignalKind, handleSaveEditedRange, handleUnlinkRange, unlinkRange, handleSetDiaIDRange, handleChangeRangesSumFlag, handleUpdateRange, handleShowMultiplicityTrees, handleShowRangesIntegrals, handleAutoSpectraRangesDetection, handleShowJGraph, };
90
+ declare function handleCutRange(draft: Draft<State>, action: CutRangAction): void;
91
+ export { handleCutRange, handleAutoRangesDetection, handleDeleteRange, deleteSignal1D, handleDeleteSignal, handleChangeRangeSum, handleAddRange, handleResizeRange, handleChangeRangeRelativeValue, handleChangeRangeSignalValue, handleChangeRangeSignalKind, handleSaveEditedRange, handleUnlinkRange, unlinkRange, handleSetDiaIDRange, handleChangeRangesSumFlag, handleUpdateRange, handleShowMultiplicityTrees, handleShowRangesIntegrals, handleAutoSpectraRangesDetection, handleShowJGraph, };
@@ -5,11 +5,12 @@ import { xFindClosestIndex } from 'ml-spectra-processing';
5
5
  import { Filters, FiltersManager } from 'nmr-processing';
6
6
  import { DatumKind, SignalKindsToInclude, } from '../../../data/constants/SignalsKinds';
7
7
  import { addRange, changeRangeSignal, detectRanges, updateRangesRelativeValues, changeRange, changeRangeRelativeValue, } from '../../../data/data1d/Spectrum1D';
8
- import { setSumOptions, } from '../../../data/data1d/Spectrum1D/SumManager';
8
+ import { initSumOptions, setSumOptions, } from '../../../data/data1d/Spectrum1D/SumManager';
9
9
  import { unlink, unlinkInAssignmentData, } from '../../../data/utilities/RangeUtilities';
10
10
  import { rangeStateInit } from '../Reducer';
11
11
  import { getActiveSpectrum } from '../helper/getActiveSpectrum';
12
12
  import getRange from '../helper/getRange';
13
+ import { getSpectrum } from '../helper/getSpectrum';
13
14
  import { handleUpdateCorrelations } from './CorrelationsActions';
14
15
  import { setDomain, setIntegralsYDomain } from './DomainActions';
15
16
  import { resetSelectedTool } from './ToolsActions';
@@ -248,6 +249,13 @@ function handleChangeRangeSum(draft, action) {
248
249
  updateRangesRelativeValues(datum, true);
249
250
  }
250
251
  }
252
+ function initiateRangeSumOptions(datum, options) {
253
+ const { nucleus, molecules } = options;
254
+ datum.ranges.options = initSumOptions(datum.ranges.options, {
255
+ molecules,
256
+ nucleus,
257
+ });
258
+ }
251
259
  //action
252
260
  function handleAddRange(draft, action) {
253
261
  const { startX, endX } = action.payload;
@@ -257,12 +265,16 @@ function handleAddRange(draft, action) {
257
265
  if (activeSpectrum?.id) {
258
266
  const { index } = activeSpectrum;
259
267
  const [from, to] = range;
260
- addRange(data[index], {
268
+ const datum = data[index];
269
+ addRange(datum, {
261
270
  from,
262
271
  to,
272
+ });
273
+ initiateRangeSumOptions(datum, {
263
274
  nucleus,
264
275
  molecules,
265
276
  });
277
+ updateRangesRelativeValues(datum);
266
278
  handleUpdateCorrelations(draft);
267
279
  setIntegralsYDomain(draft, data[index]);
268
280
  }
@@ -358,4 +370,20 @@ function handleShowJGraph(draft, action) {
358
370
  });
359
371
  }
360
372
  }
361
- export { handleAutoRangesDetection, handleDeleteRange, deleteSignal1D, handleDeleteSignal, handleChangeRangeSum, handleAddRange, handleResizeRange, handleChangeRangeRelativeValue, handleChangeRangeSignalValue, handleChangeRangeSignalKind, handleSaveEditedRange, handleUnlinkRange, unlinkRange, handleSetDiaIDRange, handleChangeRangesSumFlag, handleUpdateRange, handleShowMultiplicityTrees, handleShowRangesIntegrals, handleAutoSpectraRangesDetection, handleShowJGraph, };
373
+ function handleCutRange(draft, action) {
374
+ const { cutValue } = action.payload;
375
+ const spectrum = getSpectrum(draft);
376
+ const ranges = spectrum.ranges.values;
377
+ for (let i = 0; i < ranges.length; i++) {
378
+ const { to, from } = ranges[i];
379
+ if (cutValue > from && cutValue < to) {
380
+ ranges.splice(i, 1);
381
+ addRange(spectrum, { from, to: cutValue });
382
+ addRange(spectrum, { from: cutValue, to });
383
+ }
384
+ }
385
+ updateRangesRelativeValues(spectrum);
386
+ setIntegralsYDomain(draft, spectrum);
387
+ handleUpdateCorrelations(draft);
388
+ }
389
+ export { handleCutRange, handleAutoRangesDetection, handleDeleteRange, deleteSignal1D, handleDeleteSignal, handleChangeRangeSum, handleAddRange, handleResizeRange, handleChangeRangeRelativeValue, handleChangeRangeSignalValue, handleChangeRangeSignalKind, handleSaveEditedRange, handleUnlinkRange, unlinkRange, handleSetDiaIDRange, handleChangeRangesSumFlag, handleUpdateRange, handleShowMultiplicityTrees, handleShowRangesIntegrals, handleAutoSpectraRangesDetection, handleShowJGraph, };
@@ -4,20 +4,24 @@ import { getLocalStorage, storeData } from '../../../utility/LocalStorage';
4
4
  import { workspaceDefaultProperties } from '../../../workspaces/workspaceDefaultProperties';
5
5
  export function addWorkspace(draft, action) {
6
6
  const { workspaceKey, data } = action.payload;
7
- const newWorkSpace = lodashMerge({}, workspaceDefaultProperties,
8
7
  // eslint-disable-next-line unicorn/prefer-logical-operator-over-ternary
9
- data ? data : draft.workspaces[draft.workspace.current], {
10
- version: 1,
11
- label: workspaceKey,
12
- source: 'user',
13
- });
14
- const newWorkspaceKey = v4();
15
- const localData = getLocalStorage('nmr-general-settings');
16
- localData.currentWorkspace = newWorkspaceKey;
17
- localData.workspaces[newWorkspaceKey] = newWorkSpace;
18
- storeData('nmr-general-settings', JSON.stringify(localData));
19
- draft.workspaces[newWorkspaceKey] = newWorkSpace;
20
- draft.originalWorkspaces[newWorkspaceKey] =
21
- newWorkSpace;
22
- draft.workspace.current = newWorkspaceKey;
8
+ const workSpaceData = data
9
+ ? data
10
+ : draft.workspaces?.[draft.workspace.current];
11
+ if (workSpaceData) {
12
+ const newWorkSpace = lodashMerge({}, workspaceDefaultProperties, workSpaceData, {
13
+ version: 1,
14
+ label: workspaceKey,
15
+ source: 'user',
16
+ });
17
+ const newWorkspaceKey = v4();
18
+ const localData = getLocalStorage('nmr-general-settings');
19
+ localData.currentWorkspace = newWorkspaceKey;
20
+ localData.workspaces[newWorkspaceKey] = newWorkSpace;
21
+ storeData('nmr-general-settings', JSON.stringify(localData));
22
+ draft.workspaces[newWorkspaceKey] = newWorkSpace;
23
+ draft.originalWorkspaces[newWorkspaceKey] =
24
+ newWorkSpace;
25
+ draft.workspace.current = newWorkspaceKey;
26
+ }
23
27
  }
@@ -2,7 +2,7 @@ import { MultipleSpectraAnalysisPreferences, Workspace, WorkSpaceSource } from '
2
2
  import { Reducer } from 'react';
3
3
  import { SplitPaneSize } from 'react-science/ui';
4
4
  import { MatrixOptions } from '../../../data/types/data1d/MatrixOptions';
5
- import { NMRiumWorkspace, NMRiumPreferences } from '../../NMRium';
5
+ import type { NMRiumWorkspace, NMRiumPreferences } from '../../main';
6
6
  import { ActionType } from '../types/ActionType';
7
7
  export declare const WORKSPACES_KEYS: {
8
8
  componentKey: string;
@@ -1,3 +1,3 @@
1
1
  import { CustomWorkspaces } from 'nmr-load-save';
2
- import { NMRiumWorkspace } from '../../../NMRium';
2
+ import type { NMRiumWorkspace } from '../../../main';
3
3
  export declare function getPreferencesByWorkspace(workspace: NMRiumWorkspace, originalWorkspaces: CustomWorkspaces): Required<import("nmr-load-save").WorkspacePreferences> & import("nmr-load-save/lib/types/WorkSpace").WorkspaceMeta & import("nmr-load-save").WorkspacePreferences;
@@ -28,11 +28,21 @@ function FunctionToolBarInner({ defaultValue, ftCounter, }) {
28
28
  type: 'APPLY_FFT_FILTER',
29
29
  });
30
30
  }, [dispatch]);
31
- return (_jsxs(_Fragment, { children: [_jsxs(ToggleButtonGroup, { value: option, onChange: handleChange, children: [isButtonVisible('zoom') && (_jsx(ToggleButton, { value: options.zoom.id, id: options.zoom.id, title: `${options.zoom.label} ( Press z )`, children: _jsx(FaSearchPlus, {}) }, options.zoom.id)), isButtonVisible('zoomOut') && (_jsx(Toolbar.Item, { id: "zoom-out", onClick: handleFullZoomOut, title: "Horizontal zoom out ( Press f ), Horizontal and Vertical zoom out, double click ( Press ff )", children: _jsx(FaExpand, {}) })), isButtonVisible('peakPicking') && (_jsx(ToggleButton, { value: options.peakPicking.id, title: `${options.peakPicking.label} ( Press p )`, id: options.peakPicking.id, children: _jsx(SvgNmrPeakPicking, {}) }, options.peakPicking.id)), isButtonVisible('integral') && (_jsx(ToggleButton, { value: options.integral.id, id: options.integral.id, title: `${options.integral.label} ( Press i )`, children: _jsx(SvgNmrIntegrate, {}) }, options.integral.id)), isButtonVisible('zonePicking') && (_jsx(ToggleButton, { value: options.zonePicking.id, id: options.zonePicking.id, title: `${options.zonePicking.label} ( Press r )`, children: _jsx(FaDiceFour, {}) }, options.zonePicking.id)), isButtonVisible('slicing') && (_jsx(ToggleButton, { value: options.slicing.id, id: options.slicing.id, title: `${options.slicing.label}`, children: _jsx("p", { children: "Slic" }) }, options.slicing.id)), isButtonVisible('rangePicking') && (_jsx(ToggleButton, { value: options.rangePicking.id, title: `${options.rangePicking.label} ( Press r )`, id: options.rangePicking.id, children: _jsx(SvgNmrRangePicking, {}) }, options.rangePicking.id)), isButtonVisible('multipleSpectraAnalysis', {
31
+ const handleFFtDimension1Filter = useCallback(() => {
32
+ dispatch({
33
+ type: 'APPLY_FFT_DIMENSION_1_FILTER',
34
+ });
35
+ }, [dispatch]);
36
+ const handleFFtDimension2Filter = useCallback(() => {
37
+ dispatch({
38
+ type: 'APPLY_FFT_DIMENSION_2_FILTER',
39
+ });
40
+ }, [dispatch]);
41
+ return (_jsxs(_Fragment, { children: [_jsxs(ToggleButtonGroup, { value: option, onChange: handleChange, children: [isButtonVisible('zoom') && (_jsx(ToggleButton, { value: options.zoom.id, id: options.zoom.id, title: `${options.zoom.label}`, children: _jsx(FaSearchPlus, {}) }, options.zoom.id)), isButtonVisible('zoomOut') && (_jsx(Toolbar.Item, { id: "zoom-out", onClick: handleFullZoomOut, title: "Horizontal zoom out ( Press f ), Horizontal and Vertical zoom out, double click ( Press ff )", children: _jsx(FaExpand, {}) })), isButtonVisible('peakPicking') && (_jsx(ToggleButton, { value: options.peakPicking.id, title: `${options.peakPicking.label} ( Press p )`, id: options.peakPicking.id, children: _jsx(SvgNmrPeakPicking, {}) }, options.peakPicking.id)), isButtonVisible('integral') && (_jsx(ToggleButton, { value: options.integral.id, id: options.integral.id, title: `${options.integral.label} ( Press i )`, children: _jsx(SvgNmrIntegrate, {}) }, options.integral.id)), isButtonVisible('zonePicking') && (_jsx(ToggleButton, { value: options.zonePicking.id, id: options.zonePicking.id, title: `${options.zonePicking.label} ( Press r )`, children: _jsx(FaDiceFour, {}) }, options.zonePicking.id)), isButtonVisible('slicing') && (_jsx(ToggleButton, { value: options.slicing.id, id: options.slicing.id, title: `${options.slicing.label}`, children: _jsx("p", { children: "Slic" }) }, options.slicing.id)), isButtonVisible('rangePicking') && (_jsx(ToggleButton, { value: options.rangePicking.id, title: `${options.rangePicking.label} ( Press r )`, id: options.rangePicking.id, children: _jsx(SvgNmrRangePicking, {}) }, options.rangePicking.id)), isButtonVisible('multipleSpectraAnalysis', {
32
42
  checkSpectrumType: false,
33
43
  }) &&
34
- ftCounter > 1 && (_jsx(ToggleButton, { value: options.multipleSpectraAnalysis.id, id: options.multipleSpectraAnalysis.id, title: options.multipleSpectraAnalysis.label, children: _jsx(SvgNmrMultipleAnalysis, {}) }, options.multipleSpectraAnalysis.id)), isButtonVisible('apodization') && (_jsx(ToggleButton, { value: options.apodization.id, id: options.apodization.id, title: `${options.apodization.label} (Press a)`, children: _jsx(SvgNmrApodization, {}) }, options.apodization.id)), isButtonVisible('zeroFilling') && (_jsx(ToggleButton, { value: options.zeroFilling.id, id: options.zeroFilling.id, title: options.zeroFilling.label, children: _jsx(SvgNmrZeroFilling, {}) }, options.zeroFilling.id)), isButtonVisible('phaseCorrection') && (_jsx(ToggleButton, { value: options.phaseCorrection.id, id: options.phaseCorrection.id, title: `${options.phaseCorrection.label} ( Press a )`, children: _jsx(SvgNmrPhaseCorrection, {}) }, options.phaseCorrection.id)), isButtonVisible('baselineCorrection') && (_jsx(ToggleButton, { value: options.baselineCorrection.id, id: options.baselineCorrection.id, title: `${options.baselineCorrection.label} ( Press b )`, children: _jsx(SvgNmrBaselineCorrection, {}) }, options.baselineCorrection.id)), isButtonVisible('exclusionZones', { checkSpectrumType: false }) &&
35
- ftCounter > 0 && (_jsx(ToggleButton, { value: options.exclusionZones.id, title: `${options.exclusionZones.label} ( Press e )`, id: options.exclusionZones.id, children: _jsx("div", { style: { fontSize: 18 }, children: _jsx(SvgNmrMultipleAnalysis, {}) }) }, options.exclusionZones.id))] }), isButtonVisible('fft') && (_jsx(Toolbar.Item, { id: options.fft.id, className: "cheminfo", title: options.fft.label, onClick: handleOnFFTFilter, children: _jsx(SvgNmrFourierTransform, {}) }))] }));
44
+ ftCounter > 1 && (_jsx(ToggleButton, { value: options.multipleSpectraAnalysis.id, id: options.multipleSpectraAnalysis.id, title: options.multipleSpectraAnalysis.label, children: _jsx(SvgNmrMultipleAnalysis, {}) }, options.multipleSpectraAnalysis.id)), isButtonVisible('apodization') && (_jsx(ToggleButton, { value: options.apodization.id, id: options.apodization.id, title: `${options.apodization.label} (Press a)`, children: _jsx(SvgNmrApodization, {}) }, options.apodization.id)), isButtonVisible('zeroFilling') && (_jsx(ToggleButton, { value: options.zeroFilling.id, id: options.zeroFilling.id, title: `${options.zeroFilling.label} ( Press z )`, children: _jsx(SvgNmrZeroFilling, {}) }, options.zeroFilling.id)), isButtonVisible('phaseCorrection') && (_jsx(ToggleButton, { value: options.phaseCorrection.id, id: options.phaseCorrection.id, title: `${options.phaseCorrection.label} ( Press a )`, children: _jsx(SvgNmrPhaseCorrection, {}) }, options.phaseCorrection.id)), isButtonVisible('baselineCorrection') && (_jsx(ToggleButton, { value: options.baselineCorrection.id, id: options.baselineCorrection.id, title: `${options.baselineCorrection.label} ( Press b )`, children: _jsx(SvgNmrBaselineCorrection, {}) }, options.baselineCorrection.id)), isButtonVisible('exclusionZones', { checkSpectrumType: false }) &&
45
+ ftCounter > 0 && (_jsx(ToggleButton, { value: options.exclusionZones.id, title: `${options.exclusionZones.label} ( Press e )`, id: options.exclusionZones.id, children: _jsx("div", { style: { fontSize: 18 }, children: _jsx(SvgNmrMultipleAnalysis, {}) }) }, options.exclusionZones.id))] }), isButtonVisible('fft') && (_jsx(Toolbar.Item, { id: options.fft.id, className: "cheminfo", title: `${options.fft.label} ( Press t )`, onClick: handleOnFFTFilter, children: _jsx(SvgNmrFourierTransform, {}) })), isButtonVisible('fftDimension1') && (_jsx(Toolbar.Item, { id: options.fftDimension1.id, className: "cheminfo", title: options.fftDimension1.label, onClick: handleFFtDimension1Filter, children: _jsx(SvgNmrFourierTransform, {}) })), isButtonVisible('fftDimension2') && (_jsx(Toolbar.Item, { id: options.fftDimension2.id, className: "cheminfo", title: options.fftDimension2.label, onClick: handleFFtDimension2Filter, children: _jsx(SvgNmrFourierTransform, {}) }))] }));
36
46
  }
37
47
  const MemoizedFunctionToolBar = memo(FunctionToolBarInner);
38
48
  export default function FunctionToolBar({ defaultValue = options.zoom.id, }) {
@@ -18,6 +18,7 @@ export interface ToolOptionItem {
18
18
  isToggle: boolean;
19
19
  hasOptionPanel: boolean;
20
20
  isFilter: boolean;
21
+ isExperimental?: true;
21
22
  }
22
23
  export type Tool = keyof NMRiumToolBarPreferences | 'HMove' | 'equalizer' | 'generalSelector' | 'editRange' | 'databaseRangesSelection' | 'matrixGenerationExclusionZones';
23
24
  type RecordOptions = Record<Tool, ToolOptionItem>;