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
@@ -5,6 +5,7 @@ import { useChartData } from '../context/ChartContext';
5
5
  import { useScaleChecked } from '../context/ScaleContext';
6
6
  import useSpectrum from '../hooks/useSpectrum';
7
7
  import useXYReduce, { XYReducerDomainAxis } from '../hooks/useXYReduce';
8
+ import { useActiveSpectrum } from '../reducer/Reducer';
8
9
  import { PathBuilder } from '../utility/PathBuilder';
9
10
  import { getYScale } from './utilities/scale';
10
11
  const emptyData = { data: {}, info: {} };
@@ -18,7 +19,8 @@ function useWindowYScale() {
18
19
  });
19
20
  }
20
21
  function ApdoizationLine() {
21
- const { activeSpectrum, toolOptions: { selectedTool, data: { apodizationOptions }, }, } = useChartData();
22
+ const { toolOptions: { selectedTool, data: { apodizationOptions }, }, } = useChartData();
23
+ const activeSpectrum = useActiveSpectrum();
22
24
  const { scaleX } = useScaleChecked();
23
25
  const spectrum = useSpectrum({ emptyData });
24
26
  const xyReduce = useXYReduce(XYReducerDomainAxis.XAxis);
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/reac
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import { css } from '@emotion/react';
4
4
  import { xFindClosestIndex } from 'ml-spectra-processing';
5
- import { useContext, useCallback, Fragment, memo } from 'react';
5
+ import { useContext, Fragment, memo } from 'react';
6
6
  import { BsCursor } from 'react-icons/bs';
7
7
  import { IoPulseSharp } from 'react-icons/io5';
8
8
  import { get1DDataXY } from '../../data/data1d/Spectrum1D/get1DDataXY';
@@ -12,6 +12,7 @@ import { useChartData } from '../context/ChartContext';
12
12
  import { useScaleChecked } from '../context/ScaleContext';
13
13
  import { useFormatNumberByNucleus } from '../hooks/useFormatNumberByNucleus';
14
14
  import useSpectrum from '../hooks/useSpectrum';
15
+ import { useActiveSpectrum } from '../reducer/Reducer';
15
16
  const styles = css `
16
17
  display: flex;
17
18
  flex-firection: row;
@@ -66,14 +67,6 @@ function FooterBannerInner({ margin, width, height, activeSpectrum, spectrum, ac
66
67
  const { startX, endX, step } = useContext(BrushContext);
67
68
  const { scaleX } = useScaleChecked();
68
69
  const format = useFormatNumberByNucleus(activeTab);
69
- const getYValue = useCallback((xPosition) => {
70
- if (spectrum) {
71
- const data = get1DDataXY(spectrum);
72
- const xIndex = xFindClosestIndex(data.x, scaleX().invert(xPosition));
73
- return data.y[xIndex];
74
- }
75
- return 1;
76
- }, [spectrum, scaleX]);
77
70
  if (!position ||
78
71
  position.y < margin.top ||
79
72
  position.x < margin.left ||
@@ -81,13 +74,29 @@ function FooterBannerInner({ margin, width, height, activeSpectrum, spectrum, ac
81
74
  position.y > height - margin.bottom) {
82
75
  return _jsx("div", { css: styles });
83
76
  }
84
- return (_jsxs("div", { css: styles, children: [_jsx(BsCursor, {}), _jsxs("div", { children: [_jsx("span", { className: "label", children: " \uD835\uDEC5: " }), _jsx("span", { className: "value", children: format(scaleX().invert(position.x)) }), _jsx("span", { className: "unit", children: "ppm" }), activeSpectrum && spectrum?.info?.originFrequency && (_jsxs(_Fragment, { children: [_jsxs("span", { className: "value", children: ["\u00A0(", format(scaleX().invert(position.x) * spectrum?.info?.originFrequency, 'hz')] }), _jsx("span", { className: "unit", children: "Hz" }), _jsx("span", { className: "value", children: ") " })] }))] }), step === 'brushing' && (_jsxs("div", { children: [_jsx("span", { className: "label", children: " \u0394ppm: " }), _jsx("span", { className: "value", children: (scaleX().invert(startX) - scaleX().invert(endX)).toPrecision(6) })] })), activeSpectrum && (_jsxs(Fragment, { children: [spectrum?.info?.originFrequency && step === 'brushing' && (_jsxs("div", { children: [_jsx("span", { className: "label", children: " \u0394Hz: " }), _jsx("span", { className: "value", children: ((scaleX().invert(startX) - scaleX().invert(endX)) *
77
+ function getXIndex(xPosition) {
78
+ if (spectrum) {
79
+ const data = get1DDataXY(spectrum);
80
+ return xFindClosestIndex(data.x, scaleX().invert(xPosition));
81
+ }
82
+ return 0;
83
+ }
84
+ function getYValue(xPosition) {
85
+ if (spectrum) {
86
+ const data = get1DDataXY(spectrum);
87
+ const xIndex = getXIndex(xPosition);
88
+ return data.y[xIndex];
89
+ }
90
+ return 1;
91
+ }
92
+ return (_jsxs("div", { css: styles, children: [_jsx(BsCursor, {}), _jsxs("div", { children: [_jsx("span", { className: "label", children: " \uD835\uDEC5: " }), _jsx("span", { className: "value", children: format(scaleX().invert(position.x)) }), _jsx("span", { className: "unit", children: "ppm" }), activeSpectrum && spectrum?.info?.originFrequency && (_jsxs(_Fragment, { children: [_jsxs("span", { className: "value", children: ["\u00A0(", format(scaleX().invert(position.x) * spectrum?.info?.originFrequency, 'hz')] }), _jsx("span", { className: "unit", children: "Hz" }), _jsx("span", { className: "value", children: ") " }), _jsx("span", { children: "," }), _jsx("span", { className: "label", children: " Index: " }), _jsx("span", { className: "value", children: getXIndex(position.x) })] }))] }), step === 'brushing' && (_jsxs("div", { children: [_jsx("span", { className: "label", children: " \u0394ppm: " }), _jsx("span", { className: "value", children: (scaleX().invert(startX) - scaleX().invert(endX)).toPrecision(6) })] })), activeSpectrum && (_jsxs(Fragment, { children: [spectrum?.info?.originFrequency && step === 'brushing' && (_jsxs("div", { children: [_jsx("span", { className: "label", children: " \u0394Hz: " }), _jsx("span", { className: "value", children: ((scaleX().invert(startX) - scaleX().invert(endX)) *
85
93
  spectrum?.info?.originFrequency).toPrecision(5) })] })), step === 'brushing' && (_jsxs("div", { children: [_jsx("span", { className: "label", children: " ratio :" }), _jsxs("span", { className: "value", children: [((getYValue(startX) / (getYValue(endX) || Number.MIN_VALUE)) *
86
94
  100).toFixed(2), "%"] })] }))] })), activeSpectrum && (_jsxs(Fragment, { children: [_jsx("div", { className: "separator" }), _jsx(IoPulseSharp, {}), _jsxs("div", { children: [_jsx("span", { className: "label", children: "Intensity: " }), _jsx("span", { className: "value yvalue", children: format(getYValue(position.x)) })] })] }))] }));
87
95
  }
88
96
  const MemoizedFooterBanner = memo(FooterBannerInner);
89
97
  export default function FooterBanner() {
90
- const { margin, width, height, activeSpectrum, activeTab } = useChartData();
98
+ const { margin, width, height, view: { spectra: { activeTab }, }, } = useChartData();
99
+ const activeSpectrum = useActiveSpectrum();
91
100
  const spectrum = useSpectrum(null);
92
101
  return (_jsx(MemoizedFooterBanner, { ...{ margin, width, height, activeSpectrum, spectrum, activeTab } }));
93
102
  }
@@ -2,9 +2,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useMemo } from 'react';
3
3
  import { isSpectrum1D } from '../../data/data1d/Spectrum1D';
4
4
  import { useChartData } from '../context/ChartContext';
5
+ import { useActiveSpectrum } from '../reducer/Reducer';
5
6
  import Integral from './Integral';
6
7
  function IntegralsSeries() {
7
- const { xDomains, activeSpectrum, data, displayerKey, activeTab: nucleus, } = useChartData();
8
+ const { xDomains, data, displayerKey, view: { spectra: { activeTab: nucleus }, }, } = useChartData();
9
+ const activeSpectrum = useActiveSpectrum();
8
10
  const Integrals = useMemo(() => {
9
11
  const isActive = (id) => {
10
12
  return activeSpectrum === null ? true : id === activeSpectrum.id;
@@ -1,9 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { get1DDataXY } from '../../data/data1d/Spectrum1D/get1DDataXY';
3
3
  import { useChartData } from '../context/ChartContext';
4
+ import { useActiveSpectrum } from '../reducer/Reducer';
4
5
  import Line from './Line';
5
6
  function LinesSeries() {
6
- const { data, tempData, displayerKey, xDomains, activeSpectrum } = useChartData();
7
+ const { data, tempData, displayerKey, xDomains } = useChartData();
8
+ const activeSpectrum = useActiveSpectrum();
7
9
  let _data = tempData ? tempData : data;
8
10
  return (_jsxs("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, className: "spectrums", children: [_data
9
11
  ?.filter((d) => d.display.isVisible === true && xDomains[d.id])
@@ -39,7 +39,7 @@ function YTracker({ datum }) {
39
39
  return _jsx("span", { style: styles.value, children: datum.y[xIndex] });
40
40
  }
41
41
  function SpectraTracker() {
42
- const { data, activeTab, xDomains } = useChartData();
42
+ const { data, view: { spectra: { activeTab }, }, xDomains, } = useChartData();
43
43
  const [isVisible, toggleVisibility] = useState(false);
44
44
  useEffect(() => {
45
45
  function handler(flag) {
@@ -13,6 +13,7 @@ import { useAlert } from '../elements/popup/Alert';
13
13
  import { useModal } from '../elements/popup/Modal';
14
14
  import Spinner from '../loader/Spinner';
15
15
  import MultipletAnalysisModal from '../modal/MultipletAnalysisModal';
16
+ import { useActiveSpectrum } from '../reducer/Reducer';
16
17
  import { ZoomType } from '../reducer/helper/Zoom1DManager';
17
18
  import getRange from '../reducer/helper/getRange';
18
19
  import scaleReducer, { scaleInitialState, SET_SCALE, } from '../reducer/scaleReducer';
@@ -29,7 +30,8 @@ import VerticalIndicator from './tool/VerticalIndicator';
29
30
  import XLabelPointer from './tool/XLabelPointer';
30
31
  function Viewer1D({ emptyText = undefined }) {
31
32
  const state = useChartData();
32
- const { toolOptions: { selectedTool }, isLoading, data, mode, width: widthProp, height: heightProp, margin, activeSpectrum, xDomain, xDomains, yDomain, yDomains, verticalAlign, displayerKey, } = state;
33
+ const { toolOptions: { selectedTool }, isLoading, data, mode, width: widthProp, height: heightProp, margin, xDomain, xDomains, yDomain, yDomains, verticalAlign, displayerKey, } = state;
34
+ const activeSpectrum = useActiveSpectrum();
33
35
  const dispatch = useDispatch();
34
36
  const modal = useModal();
35
37
  const alert = useAlert();
@@ -5,6 +5,7 @@ import generateJGraphData from '../../../data/data1d/Spectrum1D/generateJGraphDa
5
5
  import { useChartData } from '../../context/ChartContext';
6
6
  import { usePanelPreferences } from '../../hooks/usePanelPreferences';
7
7
  import useSpectrum from '../../hooks/useSpectrum';
8
+ import { rangeStateInit, useActiveSpectrum } from '../../reducer/Reducer';
8
9
  import { JGraphContextProvider } from './JGraphContext';
9
10
  import { JGraphVerticalAxis } from './JGraphVerticalAxis';
10
11
  import JCouplingLinks from './JsCouplingLinks';
@@ -17,7 +18,10 @@ function InnerJGraph(props) {
17
18
  const emptyData = { ranges: {} };
18
19
  const MemoizedJGraph = memo(InnerJGraph);
19
20
  export default function JGraph() {
20
- const { height, toolOptions: { data: { showJGraph }, }, activeTab, } = useChartData();
21
+ const { height, view: { ranges: rangeState, spectra: { activeTab }, }, } = useChartData();
22
+ const activeSpectrum = useActiveSpectrum();
23
+ const { showJGraph } = rangeState.find((r) => r.spectrumID === activeSpectrum?.id) ||
24
+ rangeStateInit;
21
25
  const rangesPreferences = usePanelPreferences('ranges', activeTab);
22
26
  const graphHeight = height / 4;
23
27
  const { ranges } = useSpectrum(emptyData);
@@ -19,6 +19,6 @@ function MultiAnalysisRangesInner({ activeTab, spectraAnalysis, displayerKey, })
19
19
  }
20
20
  const MemoizedMultiAnalysisRanges = memo(MultiAnalysisRangesInner);
21
21
  export default function MultiAnalysisRanges() {
22
- const { activeTab, spectraAnalysis, displayerKey } = useChartData();
22
+ const { view: { spectra: { activeTab }, }, spectraAnalysis, displayerKey, } = useChartData();
23
23
  return (_jsx(MemoizedMultiAnalysisRanges, { ...{ activeTab, spectraAnalysis, displayerKey } }));
24
24
  }
@@ -7,6 +7,7 @@ import { useChartData } from '../../context/ChartContext';
7
7
  import { useScaleChecked } from '../../context/ScaleContext';
8
8
  import { HighlightEventSource, useHighlight } from '../../highlight';
9
9
  import { hasCouplingConstant, checkMultiplicity, } from '../../panels/extra/utilities/MultiplicityUtilities';
10
+ import { useActiveSpectrum } from '../../reducer/Reducer';
10
11
  import { options } from '../../toolbar/ToolTypes';
11
12
  import LevelNode from './LevelNode';
12
13
  import StringNode from './StringNode';
@@ -25,7 +26,8 @@ function MultiplicityTree({ rangeFrom, rangeTo, signal, labelOptions = {
25
26
  fontSize: 11,
26
27
  }, }) {
27
28
  const { scaleX, scaleY } = useScaleChecked();
28
- const { data: spectraData, activeSpectrum, toolOptions: { selectedTool }, width, } = useChartData();
29
+ const { data: spectraData, toolOptions: { selectedTool }, width, } = useChartData();
30
+ const activeSpectrum = useActiveSpectrum();
29
31
  const assignment = useAssignment(signal.id);
30
32
  const highlight = useHighlight(extractID(assignment), {
31
33
  type: HighlightEventSource.SIGNAL,
@@ -3,11 +3,13 @@ import { useMemo } from 'react';
3
3
  import { useChartData } from '../../context/ChartContext';
4
4
  import { useScaleChecked } from '../../context/ScaleContext';
5
5
  import useSpectrum from '../../hooks/useSpectrum';
6
+ import { useActiveSpectrum } from '../../reducer/Reducer';
6
7
  import getVerticalShift from '../utilities/getVerticalShift';
7
8
  import PeakAnnotation from './PeakAnnotation';
8
9
  const emptyData = { peaks: {}, info: {}, display: {} };
9
10
  function PeakAnnotations() {
10
- const { activeSpectrum, verticalAlign, displayerKey } = useChartData();
11
+ const { verticalAlign, displayerKey } = useChartData();
12
+ const activeSpectrum = useActiveSpectrum();
11
13
  const { scaleX, scaleY } = useScaleChecked();
12
14
  const spectrum = useSpectrum(emptyData);
13
15
  const Peaks = useMemo(() => {
@@ -1,11 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useChartData } from '../../context/ChartContext';
3
3
  import useSpectrum from '../../hooks/useSpectrum';
4
+ import { useActiveSpectrum } from '../../reducer/Reducer';
4
5
  import getVerticalShift from '../utilities/getVerticalShift';
5
6
  import { usePeakShapesPath } from './usePeakShapesPath';
6
7
  const emptyData = { peaks: {}, display: {} };
7
8
  function PeaksShapes() {
8
- const { activeSpectrum, verticalAlign, displayerKey, toolOptions: { data: { peaksOptions: { showPeaksShapes, showPeaksSum }, }, }, } = useChartData();
9
+ const { verticalAlign, displayerKey, toolOptions: { data: { peaksOptions: { showPeaksShapes, showPeaksSum }, }, }, } = useChartData();
10
+ const activeSpectrum = useActiveSpectrum();
9
11
  const spectrum = useSpectrum(emptyData);
10
12
  if (!spectrum?.peaks?.values || !spectrum.display.isVisible) {
11
13
  return null;
@@ -20,7 +22,7 @@ function PeaksShapesItems(props) {
20
22
  const getPath = usePeakShapesPath(spectrum);
21
23
  return (_jsxs("g", { children: [' ', spectrum.peaks.values.map((peak) => {
22
24
  const { fill, path } = getPath({ target: 'peakShape', peak });
23
- return (_jsx("path", { stroke: 'red', fill: fill, fillOpacity: 0.3, d: path, transform: `translate(0,-${props.vAlign})` }, peak.id));
25
+ return (_jsx("path", { fill: fill, fillOpacity: 0.3, d: path, transform: `translate(0,-${props.vAlign})` }, peak.id));
24
26
  })] }));
25
27
  }
26
28
  function PeaksShapesSum(props) {
@@ -7,16 +7,20 @@ export function usePeakShapesPath(spectrum) {
7
7
  const { width, xDomain } = useChartData();
8
8
  return function getPath(options) {
9
9
  const { target } = options;
10
+ const frequency = spectrum.info.originFrequency;
10
11
  let pathSeries = null;
11
12
  switch (target) {
12
13
  case 'peakShape':
13
14
  pathSeries = peakToXY(options.peak, {
14
- frequency: spectrum.info.originFrequency,
15
+ frequency,
16
+ nbPoints: 1024,
17
+ from: options.peak.x - (options.peak.width / frequency) * 9,
18
+ to: options.peak.x + (options.peak.width / frequency) * 9,
15
19
  });
16
20
  break;
17
21
  case 'peaksSum':
18
22
  pathSeries = peaksToXY(options.peaks, {
19
- frequency: spectrum.info.originFrequency,
23
+ frequency,
20
24
  nbPoints: width,
21
25
  from: xDomain[0],
22
26
  to: xDomain[1],
@@ -37,7 +41,7 @@ export function usePeakShapesPath(spectrum) {
37
41
  }
38
42
  if (target === 'peakShape') {
39
43
  pathBuilder.closePath();
40
- fill = 'red';
44
+ fill = 'black';
41
45
  }
42
46
  }
43
47
  return { path: pathBuilder.toString(), fill };
@@ -1,8 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Fragment, memo } from 'react';
2
+ import { Fragment, memo, useMemo } from 'react';
3
3
  import { useChartData } from '../../context/ChartContext';
4
4
  import { usePanelPreferences } from '../../hooks/usePanelPreferences';
5
5
  import useSpectrum from '../../hooks/useSpectrum';
6
+ import { rangeStateInit, useActiveSpectrum } from '../../reducer/Reducer';
6
7
  import Range from './Range';
7
8
  import RangeIntegral from './RangeIntegral';
8
9
  function RangesInner({ ranges, displayerKey, selectedTool, showMultiplicityTrees, showRangesIntegrals, relativeFormat, }) {
@@ -11,7 +12,12 @@ function RangesInner({ ranges, displayerKey, selectedTool, showMultiplicityTrees
11
12
  const MemoizedRanges = memo(RangesInner);
12
13
  const empyData = { ranges: {} };
13
14
  export default function Ranges() {
14
- const { displayerKey, toolOptions: { selectedTool, data: { showMultiplicityTrees, showRangesIntegrals }, }, activeTab, } = useChartData();
15
+ const { displayerKey, view: { ranges: rangeState, spectra: { activeTab }, }, toolOptions: { selectedTool }, } = useChartData();
16
+ const activeSpectrum = useActiveSpectrum();
17
+ const { showMultiplicityTrees, showRangesIntegrals } = useMemo(() => activeSpectrum
18
+ ? rangeState.find((r) => r.spectrumID === activeSpectrum.id) ||
19
+ rangeStateInit
20
+ : rangeStateInit, [activeSpectrum, rangeState]);
15
21
  const { ranges } = useSpectrum(empyData);
16
22
  const rangesPreferences = usePanelPreferences('ranges', activeTab);
17
23
  return (_jsx(MemoizedRanges, { ...{
@@ -6,6 +6,7 @@ import { BrushContext } from '../../EventsTrackers/BrushTracker';
6
6
  import { MouseContext } from '../../EventsTrackers/MouseTracker';
7
7
  import { useChartData } from '../../context/ChartContext';
8
8
  import { useScaleChecked } from '../../context/ScaleContext';
9
+ import { useActiveSpectrum } from '../../reducer/Reducer';
9
10
  import { options } from '../../toolbar/ToolTypes';
10
11
  import getVerticalShift from '../utilities/getVerticalShift';
11
12
  const styles = {
@@ -16,8 +17,9 @@ const styles = {
16
17
  SVGPadding: 1,
17
18
  };
18
19
  function PeakPointer() {
19
- const { height, width, margin, activeSpectrum, data, mode, toolOptions: { selectedTool }, verticalAlign, } = useChartData();
20
+ const { height, width, margin, data, mode, toolOptions: { selectedTool }, verticalAlign, } = useChartData();
20
21
  const { scaleX, scaleY } = useScaleChecked();
22
+ const activeSpectrum = useActiveSpectrum();
21
23
  let position = useContext(MouseContext);
22
24
  const brushState = useContext(BrushContext);
23
25
  const [closePeakPosition, setPosition] = useState();
@@ -5,6 +5,7 @@ import { MouseContext } from '../../EventsTrackers/MouseTracker';
5
5
  import { useChartData } from '../../context/ChartContext';
6
6
  import { useScaleChecked } from '../../context/ScaleContext';
7
7
  import { useFormatNumberByNucleus } from '../../hooks/useFormatNumberByNucleus';
8
+ import { useActiveSpectrum } from '../../reducer/Reducer';
8
9
  const style = {
9
10
  cursor: 'crosshair',
10
11
  transformOrigin: 'bottom right',
@@ -16,7 +17,8 @@ const style = {
16
17
  userSelect: 'none',
17
18
  };
18
19
  function XLabelPointer() {
19
- const { height, width, margin, data, activeSpectrum } = useChartData();
20
+ const { height, width, margin, data } = useChartData();
21
+ const activeSpectrum = useActiveSpectrum();
20
22
  const { scaleX } = useScaleChecked();
21
23
  const position = useContext(MouseContext);
22
24
  const brushState = useContext(BrushContext);
@@ -4,10 +4,12 @@ import { memo, useMemo } from 'react';
4
4
  import { getShift } from '../../data/data2d/Spectrum2D';
5
5
  import { useChartData } from '../context/ChartContext';
6
6
  import { usePreferences } from '../context/PreferencesContext';
7
+ import { useActiveSpectrum } from '../reducer/Reducer';
7
8
  import { PathBuilder } from '../utility/PathBuilder';
8
9
  import { get2DXScale, get2DYScale } from './utilities/scale';
9
10
  function ContoursPaths({ id: spectrumID, sign, color, datum, }) {
10
- const { margin, width, height, xDomain, yDomain, contours, activeSpectrum } = useChartData();
11
+ const { margin, width, height, xDomain, yDomain, contours } = useChartData();
12
+ const activeSpectrum = useActiveSpectrum();
11
13
  const preferences = usePreferences();
12
14
  const { xShift, yShift } = getShift(datum);
13
15
  const isActive = useMemo(() => {
@@ -46,7 +48,7 @@ function ContoursPaths({ id: spectrumID, sign, color, datum, }) {
46
48
  return (_jsx("path", { fill: "none", "data-test-id": "spectrum-line", stroke: color, strokeWidth: "1", style: {
47
49
  opacity: isActive
48
50
  ? 1
49
- : get(preferences.current, 'general.dimmedSpectraTransparency', 0.1),
51
+ : get(preferences.current, 'general.dimmedSpectraOpacity', 0.1),
50
52
  }, d: path }));
51
53
  }
52
54
  function ContoursInner({ data, displayerKey }) {
@@ -9,6 +9,7 @@ import { BrushContext } from '../EventsTrackers/BrushTracker';
9
9
  import { MouseContext } from '../EventsTrackers/MouseTracker';
10
10
  import { useChartData } from '../context/ChartContext';
11
11
  import { useFormatNumberByNucleus } from '../hooks/useFormatNumberByNucleus';
12
+ import { useActiveSpectrum } from '../reducer/Reducer';
12
13
  import { options } from '../toolbar/ToolTypes';
13
14
  import { getLayoutID, LAYOUT } from './utilities/DimensionLayout';
14
15
  import { get2DXScale, get1DYScale, get2DYScale } from './utilities/scale';
@@ -49,7 +50,8 @@ const styles = css `
49
50
  function FooterBanner({ layout, data1D }) {
50
51
  const position = useContext(MouseContext);
51
52
  const { startX, endX, startY, endY, step } = useContext(BrushContext);
52
- const { margin, width, height, activeSpectrum, xDomain, yDomain, yDomains, activeTab, data, toolOptions: { selectedTool }, } = useChartData();
53
+ const { margin, width, height, xDomain, yDomain, yDomains, view: { spectra: { activeTab }, }, data, toolOptions: { selectedTool }, } = useChartData();
54
+ const activeSpectrum = useActiveSpectrum();
53
55
  const trackID = position &&
54
56
  getLayoutID(layout, {
55
57
  startX: position.x,
@@ -41,6 +41,6 @@ function Left1DChart({ margin: marignValue = 10, data: spectrum, }) {
41
41
  const mainHeight = originHeight - margin.bottom - margin.top;
42
42
  if (!mainHeight || !height)
43
43
  return null;
44
- return (_jsxs("svg", { viewBox: `0 0 ${height} ${mainHeight + margin.top}`, width: height, height: mainHeight + margin.top, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-left`, children: _jsx("rect", { width: height, height: mainHeight, x: "0", y: margin.top }) }) }), _jsx("g", { clipPath: `url(#${displayerKey}clip-left)`, children: _jsx("path", { className: "line", stroke: "black", fill: "none", d: paths }) })] }));
44
+ return (_jsxs("svg", { viewBox: `0 0 ${height} ${mainHeight + margin.top}`, width: height, height: mainHeight + margin.top, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-left`, children: _jsx("rect", { width: height, height: mainHeight, x: "0", y: margin.top }) }) }), _jsx("g", { clipPath: `url(#${displayerKey}clip-left)`, children: _jsx("path", { className: "line", stroke: spectrum.display.color, fill: "none", d: paths }) })] }));
45
45
  }
46
46
  export default memo(Left1DChart);
@@ -37,6 +37,6 @@ function Top1DChart({ margin: marginProps = 10, data: spectrum, }) {
37
37
  if (!width || !height) {
38
38
  return null;
39
39
  }
40
- return (_jsxs("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-top`, children: _jsx("rect", { width: width - originMargin.left - originMargin.right, height: height, x: originMargin.left, y: `${0}` }) }) }), _jsx("g", { clipPath: `url(#${displayerKey}clip-top)`, children: _jsx("path", { className: "line", stroke: "red", fill: "none", strokeWidth: "1px", d: paths }) })] }));
40
+ return (_jsxs("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-top`, children: _jsx("rect", { width: width - originMargin.left - originMargin.right, height: height, x: originMargin.left, y: `${0}` }) }) }), _jsx("g", { clipPath: `url(#${displayerKey}clip-top)`, children: _jsx("path", { className: "line", stroke: spectrum.display.color, fill: "none", strokeWidth: "1px", d: paths }) })] }));
41
41
  }
42
42
  export default memo(Top1DChart);
@@ -19,15 +19,15 @@ import SlicingView from './tools/slicing/SlicingView';
19
19
  import { get2DDimensionLayout, getLayoutID } from './utilities/DimensionLayout';
20
20
  function Viewer2D({ emptyText = undefined }) {
21
21
  const state = useChartData();
22
- const { toolOptions: { selectedTool }, isLoading, data, margin, tabActiveSpectrum, activeTab, } = state;
22
+ const { toolOptions: { selectedTool }, isLoading, data, margin, view: { spectra: { activeSpectra, activeTab }, }, } = state;
23
23
  const dispatch = useDispatch();
24
24
  const { info } = useSpectrum({ info: {} });
25
25
  const isVisible = info.isFt || !('isFt' in info);
26
26
  const spectrumData = useMemo(() => {
27
27
  const nucleuses = activeTab.split(',');
28
28
  return nucleuses.reduce((acc, n) => {
29
- if (tabActiveSpectrum[n]?.id) {
30
- const id = tabActiveSpectrum[n]?.id;
29
+ if (activeSpectra[n]?.id) {
30
+ const id = activeSpectra[n]?.id;
31
31
  const spectrum = data.find((datum) => datum.id === id && !datum.info.isFid);
32
32
  if (spectrum) {
33
33
  acc.push(spectrum);
@@ -38,7 +38,7 @@ function Viewer2D({ emptyText = undefined }) {
38
38
  }
39
39
  return acc;
40
40
  }, []);
41
- }, [activeTab, data, tabActiveSpectrum]);
41
+ }, [activeTab, data, activeSpectra]);
42
42
  const DIMENSION = get2DDimensionLayout(state);
43
43
  const handelBrushEnd = useCallback((brushData) => {
44
44
  const trackID = getLayoutID(DIMENSION, brushData);
@@ -21,7 +21,7 @@ const defaultMargin = { right: 100, top: 0, left: 0, bottom: 0 };
21
21
  function XAxis(props) {
22
22
  const { show = true, label = 'δ [ppm]', margin: marginProps = defaultMargin, } = props;
23
23
  const state = useChartData();
24
- const { xDomain, height, width, margin, tabActiveSpectrum, activeTab } = state;
24
+ const { xDomain, height, width, margin, view: { spectra: { activeSpectra, activeTab }, }, } = state;
25
25
  const refAxis = useRef(null);
26
26
  useEffect(() => {
27
27
  if (!show)
@@ -39,7 +39,7 @@ function XAxis(props) {
39
39
  margin.right,
40
40
  margin.top,
41
41
  show,
42
- tabActiveSpectrum,
42
+ activeSpectra,
43
43
  width,
44
44
  xDomain,
45
45
  ]);
@@ -26,7 +26,7 @@ function YAxis(props) {
26
26
  const { show = true, label = '', margin: marginProps = defaultMargin, } = props;
27
27
  const refAxis = useRef(null);
28
28
  const state = useChartData();
29
- const { yDomain, width, height, activeTab, tabActiveSpectrum, margin } = state;
29
+ const { yDomain, width, height, view: { spectra: { activeTab, activeSpectra }, }, margin, } = state;
30
30
  useEffect(() => {
31
31
  if (!show || !yDomain)
32
32
  return;
@@ -34,7 +34,7 @@ function YAxis(props) {
34
34
  const axis = d3.axisRight(scaleY).ticks(8).tickFormat(d3.format('0'));
35
35
  // @ts-expect-error well typed
36
36
  d3.select(refAxis.current).call(axis);
37
- }, [show, yDomain, activeTab, tabActiveSpectrum, height, margin]);
37
+ }, [show, yDomain, activeTab, activeSpectra, height, margin]);
38
38
  if (!width || !height) {
39
39
  return null;
40
40
  }
@@ -4,6 +4,7 @@ import { BrushContext } from '../../EventsTrackers/BrushTracker';
4
4
  import { MouseContext } from '../../EventsTrackers/MouseTracker';
5
5
  import { useChartData } from '../../context/ChartContext';
6
6
  import { useFormatNumberByNucleus } from '../../hooks/useFormatNumberByNucleus';
7
+ import { useActiveSpectrum } from '../../reducer/Reducer';
7
8
  import { getLayoutID, LAYOUT } from '../utilities/DimensionLayout';
8
9
  import { get2DXScale, get2DYScale, get1DYScale } from '../utilities/scale';
9
10
  const style = {
@@ -22,7 +23,8 @@ const style = {
22
23
  function XYLabelPointer({ layout, data1D }) {
23
24
  const position = useContext(MouseContext);
24
25
  const { step } = useContext(BrushContext);
25
- const { margin, width, height, xDomain, yDomain, yDomains, activeTab, activeSpectrum, } = useChartData();
26
+ const { margin, width, height, xDomain, yDomain, yDomains, view: { spectra: { activeTab }, }, } = useChartData();
27
+ const activeSpectrum = useActiveSpectrum();
26
28
  const trackID = position &&
27
29
  getLayoutID(layout, {
28
30
  startX: position.x,
@@ -3,12 +3,14 @@ import { useMemo } from 'react';
3
3
  import { getSlice } from '../../../../data/data2d/Spectrum2D';
4
4
  import { useMouseTracker } from '../../../EventsTrackers/MouseTracker';
5
5
  import { useChartData } from '../../../context/ChartContext';
6
+ import { useActiveSpectrum } from '../../../reducer/Reducer';
6
7
  import { get2DXScale, get2DYScale } from '../../utilities/scale';
7
8
  import HorizontalSliceChart from './HorizontalSliceChart';
8
9
  import VerticalSliceChart from './VerticalSliceChart';
9
10
  function SlicingView() {
10
- const { width, height, margin, activeSpectrum, data: spectra, xDomain, yDomain, } = useChartData();
11
+ const { width, height, margin, data: spectra, xDomain, yDomain, } = useChartData();
11
12
  const position = useMouseTracker();
13
+ const activeSpectrum = useActiveSpectrum();
12
14
  const chart2d = useMemo(() => {
13
15
  if (position && activeSpectrum && activeSpectrum.id) {
14
16
  const { x, y } = position;
@@ -11,7 +11,7 @@ const lineStyle = css `
11
11
  opacity: 0.7;
12
12
  `;
13
13
  function IndicationLines({ axis, show }) {
14
- const { data, activeTab, margin, width, height, xDomain, yDomain, displayerMode, } = useChartData();
14
+ const { data, view: { spectra: { activeTab }, }, margin, width, height, xDomain, yDomain, displayerMode, } = useChartData();
15
15
  const [deltas1D, setDeltas1D] = useState([]);
16
16
  const scaleX = get2DXScale({ margin, width, xDomain });
17
17
  const scaleY = get2DYScale({ margin, height, yDomain });
@@ -1,30 +1,25 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useState, memo } from 'react';
2
+ import { memo, useMemo } from 'react';
3
3
  import { useChartData } from '../../context/ChartContext';
4
4
  import useSpectrum from '../../hooks/useSpectrum';
5
- import Events from '../../utility/Events';
5
+ import { zoneStateInit } from '../../reducer/Reducer';
6
6
  import Zone from './Zone';
7
- function ZonesInner({ zones, display, displayerKey }) {
8
- const [isVisible, setVisibility] = useState({
9
- zones: true,
10
- signals: true,
11
- peaks: true,
12
- });
13
- useEffect(() => {
14
- Events.on('onZonesVisibilityChange', ({ key }) => {
15
- setVisibility((prevVisiblity) => ({
16
- ...prevVisiblity,
17
- [key]: !prevVisiblity[key],
18
- }));
19
- });
20
- }, []);
7
+ function ZonesInner({ zones, display, displayerKey, isVisible, }) {
21
8
  return (_jsx("g", { clipPath: `url(#${displayerKey}clip-chart-2d)`, className: "2D-Zones", children: display.isVisible &&
22
9
  zones.values.map((zone) => (_jsx("g", { className: "zone", children: _jsx(Zone, { zoneData: zone, isVisible: isVisible }) }, zone.id))) }));
23
10
  }
24
11
  const MemoizedZones = memo(ZonesInner);
25
12
  const emptyData = { zones: {}, display: {} };
26
13
  export default function Zones() {
27
- const { displayerKey } = useChartData();
28
- const { zones, display } = useSpectrum(emptyData);
29
- return _jsx(MemoizedZones, { ...{ zones, display, displayerKey } });
14
+ const { displayerKey, view: { zones: zoneState }, } = useChartData();
15
+ const { zones, display, id } = useSpectrum(emptyData);
16
+ const isVisible = useMemo(() => {
17
+ const { showPeaks, showSignals, showZones } = zoneState.find((r) => r.spectrumID === id) || zoneStateInit;
18
+ return {
19
+ zones: showZones,
20
+ signals: showSignals,
21
+ peaks: showPeaks,
22
+ };
23
+ }, [id, zoneState]);
24
+ return _jsx(MemoizedZones, { ...{ zones, display, displayerKey, isVisible } });
30
25
  }
@@ -13,6 +13,9 @@ const initialState = {
13
13
  startY: 0,
14
14
  endY: 0,
15
15
  };
16
+ function stopPageScrolling(event) {
17
+ event.preventDefault();
18
+ }
16
19
  export const BrushContext = createContext(initialState);
17
20
  export function BrushTracker({ children, className, style, onBrush = () => null, onZoom = () => null, onDoubleClick = () => null, onClick = () => null, noPropagation, }) {
18
21
  const [state, dispatch] = useReducer(reducer, initialState);
@@ -35,6 +38,24 @@ export function BrushTracker({ children, className, style, onBrush = () => null,
35
38
  });
36
39
  setMouseDownTime(event.timeStamp);
37
40
  }
41
+ function moveCallback(event) {
42
+ dispatch({
43
+ type: 'MOVE',
44
+ screenX: event.screenX,
45
+ screenY: event.screenY,
46
+ clientX: event.clientX,
47
+ clientY: event.clientY,
48
+ });
49
+ }
50
+ function mouseUpCallback() {
51
+ dispatch({
52
+ type: 'UP',
53
+ });
54
+ window.removeEventListener('mousemove', moveCallback);
55
+ window.removeEventListener('mouseup', mouseUpCallback);
56
+ }
57
+ window.addEventListener('mousemove', moveCallback);
58
+ window.addEventListener('mouseup', mouseUpCallback);
38
59
  return false;
39
60
  }, [noPropagation]);
40
61
  const clickHandler = useCallback((e) => {
@@ -74,34 +95,22 @@ export function BrushTracker({ children, className, style, onBrush = () => null,
74
95
  });
75
96
  }
76
97
  }, [onBrush, state]);
77
- const moveCallback = useCallback((event) => {
78
- dispatch({
79
- type: 'MOVE',
80
- screenX: event.screenX,
81
- screenY: event.screenY,
82
- clientX: event.clientX,
83
- clientY: event.clientY,
84
- });
85
- }, []);
86
- const upCallback = useCallback((event) => {
87
- dispatch({
88
- type: 'UP',
89
- clientX: event.clientX,
90
- clientY: event.clientY,
91
- });
92
- return false;
93
- }, []);
94
- return (_jsx(BrushContext.Provider, { value: state, children: _jsx("div", { className: className, style: style, onMouseDown: mouseDownHandler, onMouseUp: upCallback, onMouseMove: moveCallback, onClick: clickHandler, onWheel: handleMouseWheel, children: children }) }));
98
+ return (_jsx(BrushContext.Provider, { value: state, children: _jsx("div", { className: className, style: style, onMouseDown: mouseDownHandler, onClick: clickHandler, onWheel: handleMouseWheel, onMouseEnter: () => {
99
+ // disable page scrolling once the mouse over the Displayer
100
+ window.addEventListener('wheel', stopPageScrolling, {
101
+ passive: false,
102
+ });
103
+ }, onMouseLeave: () => {
104
+ // disable page scrolling once the mouse over the Displayer
105
+ window.removeEventListener('wheel', stopPageScrolling);
106
+ }, children: children }) }));
95
107
  }
96
108
  function reducer(state, action) {
97
109
  switch (action.type) {
98
110
  case 'UP':
99
111
  if (state.step === 'brushing' || state.step === 'start') {
100
- const { clientX, clientY } = action;
101
112
  return {
102
113
  ...state,
103
- endX: clientX - state.boundingRect.x,
104
- endY: clientY - state.boundingRect.y,
105
114
  step: state.step === 'start' ? 'initial' : 'end',
106
115
  };
107
116
  }