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