nmrium 0.30.0 → 0.31.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 +3 -1
- 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 +3 -1
- package/lib/component/2d/FooterBanner.js +3 -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/NMRium.d.ts +2 -0
- package/lib/component/NMRium.js +14 -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 +2 -2
- 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 +7 -147
- package/lib/component/modal/changeSum/SelectMolecule.js +1 -1
- package/lib/component/modal/editRange/EditRangeModal.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/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/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/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 +108 -49
- 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 +11 -9
- package/lib/component/reducer/actions/FiltersActions.d.ts +1 -1
- package/lib/component/reducer/actions/FiltersActions.js +218 -232
- package/lib/component/reducer/actions/IntegralsActions.js +13 -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 +18 -12
- package/lib/component/reducer/actions/PreferencesActions.js +8 -10
- package/lib/component/reducer/actions/RangesActions.d.ts +3 -3
- package/lib/component/reducer/actions/RangesActions.js +85 -27
- package/lib/component/reducer/actions/SpectraAnalysisAction.js +5 -5
- package/lib/component/reducer/actions/SpectrumsActions.js +13 -10
- package/lib/component/reducer/actions/ToolsActions.js +38 -23
- package/lib/component/reducer/actions/ZonesActions.d.ts +4 -1
- package/lib/component/reducer/actions/ZonesActions.js +68 -17
- package/lib/component/reducer/helper/Zoom1DManager.js +2 -1
- 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/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 +4 -6
- package/lib/component/toolbar/FunctionToolBar.js +3 -1
- package/lib/component/utility/assert.d.ts +1 -0
- package/lib/component/utility/assert.js +5 -0
- package/lib/component/workspaces/exercise.js +6 -0
- 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/utils/padDataToNextPowerOfTwo.d.ts +2 -0
- package/lib/data/data1d/filter1d/utils/padDataToNextPowerOfTwo.js +35 -0
- package/lib/data/data2d/Spectrum2D/zones/getDetectionZones.d.ts +1 -1
- package/lib/data/molecules/Molecule.d.ts +5 -0
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/ApodizationLine.js +3 -1
- package/lib-cjs/component/1d/FooterBanner.js +3 -1
- 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 +3 -1
- package/lib-cjs/component/2d/FooterBanner.js +3 -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/NMRium.js +14 -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 +2 -2
- 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 +6 -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/ToolsTabContent.js +4 -0
- package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.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/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/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 +11 -9
- package/lib-cjs/component/reducer/actions/FiltersActions.js +219 -233
- package/lib-cjs/component/reducer/actions/IntegralsActions.js +13 -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 +18 -12
- package/lib-cjs/component/reducer/actions/PreferencesActions.js +8 -10
- package/lib-cjs/component/reducer/actions/RangesActions.js +85 -27
- package/lib-cjs/component/reducer/actions/SpectraAnalysisAction.js +5 -5
- package/lib-cjs/component/reducer/actions/SpectrumsActions.js +13 -10
- package/lib-cjs/component/reducer/actions/ToolsActions.js +38 -23
- package/lib-cjs/component/reducer/actions/ZonesActions.js +71 -17
- package/lib-cjs/component/reducer/helper/Zoom1DManager.js +2 -1
- 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 +4 -6
- package/lib-cjs/component/toolbar/FunctionToolBar.js +3 -1
- package/lib-cjs/component/utility/assert.js +9 -0
- package/lib-cjs/component/workspaces/exercise.js +6 -0
- 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/utils/padDataToNextPowerOfTwo.js +39 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +22 -22
- 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/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/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
|
@@ -42,6 +42,7 @@ const ToolTypes_1 = require("../../toolbar/ToolTypes");
|
|
|
42
42
|
const getSpectraByNucleus_1 = require("../../utility/getSpectraByNucleus");
|
|
43
43
|
const nucleusToString_1 = __importDefault(require("../../utility/nucleusToString"));
|
|
44
44
|
const ZoomHistoryManager_1 = __importDefault(require("../helper/ZoomHistoryManager"));
|
|
45
|
+
const getActiveSpectrumOrFail_1 = require("../helper/getActiveSpectrumOrFail");
|
|
45
46
|
const getRange_1 = __importDefault(require("../helper/getRange"));
|
|
46
47
|
const getStrongestPeak_1 = require("../helper/getStrongestPeak");
|
|
47
48
|
const DomainActions_1 = require("./DomainActions");
|
|
@@ -49,215 +50,202 @@ const PreferencesActions_1 = require("./PreferencesActions");
|
|
|
49
50
|
const ToolsActions_1 = require("./ToolsActions");
|
|
50
51
|
function shiftSpectrumAlongXAxis(draft, shiftValue) {
|
|
51
52
|
//apply filter into the spectrum
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
53
|
+
const activeSpectrum = (0, getActiveSpectrumOrFail_1.getActiveSpectrumOrFail)(draft);
|
|
54
|
+
const index = activeSpectrum?.index;
|
|
55
|
+
FiltersManager.applyFilter(draft.data[index], [
|
|
56
|
+
{ name: Filters.shiftX.id, options: shiftValue },
|
|
57
|
+
]);
|
|
58
|
+
(0, Spectrum1D_1.updateXShift)(draft.data[index]);
|
|
59
|
+
(0, ToolsActions_1.resetSelectedTool)(draft);
|
|
60
|
+
(0, DomainActions_1.setDomain)(draft);
|
|
61
61
|
}
|
|
62
62
|
exports.shiftSpectrumAlongXAxis = shiftSpectrumAlongXAxis;
|
|
63
63
|
function applyZeroFillingFilter(draft, action) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
64
|
+
const activeSpectrum = (0, getActiveSpectrumOrFail_1.getActiveSpectrumOrFail)(draft);
|
|
65
|
+
const index = activeSpectrum.index;
|
|
66
|
+
const { size } = action.payload;
|
|
67
|
+
const filters = [
|
|
68
|
+
{
|
|
69
|
+
name: Filters.zeroFilling.id,
|
|
70
|
+
options: size,
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
FiltersManager.applyFilter(draft.data[index], filters);
|
|
74
|
+
(0, ToolsActions_1.resetSelectedTool)(draft);
|
|
75
|
+
(0, DomainActions_1.setDomain)(draft);
|
|
76
|
+
(0, DomainActions_1.setMode)(draft);
|
|
78
77
|
}
|
|
79
78
|
exports.applyZeroFillingFilter = applyZeroFillingFilter;
|
|
80
79
|
function calculateApodizationFilter(draft, action) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
80
|
+
const activeSpectrum = (0, getActiveSpectrumOrFail_1.getActiveSpectrumOrFail)(draft);
|
|
81
|
+
const index = activeSpectrum.index;
|
|
82
|
+
const options = action.payload;
|
|
83
|
+
const { data: { x, re, im }, info, } = draft.data[index];
|
|
84
|
+
let _data = { data: { x, re, im }, info };
|
|
85
|
+
draft.toolOptions.data.apodizationOptions = options;
|
|
86
|
+
(0, apodization_1.apply)(_data, options);
|
|
87
|
+
const { im: newIm, re: newRe } = _data.data;
|
|
88
|
+
draft.tempData[index].data.im = newIm;
|
|
89
|
+
draft.tempData[index].data.re = newRe;
|
|
92
90
|
}
|
|
93
91
|
exports.calculateApodizationFilter = calculateApodizationFilter;
|
|
94
92
|
function applyApodizationFilter(draft, action) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
93
|
+
const activeSpectrum = (0, getActiveSpectrumOrFail_1.getActiveSpectrumOrFail)(draft);
|
|
94
|
+
const index = activeSpectrum.index;
|
|
95
|
+
const options = action.payload;
|
|
96
|
+
const filters = [
|
|
97
|
+
{
|
|
98
|
+
name: Filters.apodization.id,
|
|
99
|
+
options,
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
FiltersManager.applyFilter(draft.data[index], filters);
|
|
103
|
+
(0, ToolsActions_1.resetSelectedTool)(draft);
|
|
104
|
+
(0, DomainActions_1.setDomain)(draft);
|
|
105
|
+
(0, DomainActions_1.setMode)(draft);
|
|
109
106
|
}
|
|
110
107
|
exports.applyApodizationFilter = applyApodizationFilter;
|
|
111
108
|
function calculateZeroFillingFilter(draft, action) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
109
|
+
const activeSpectrum = (0, getActiveSpectrumOrFail_1.getActiveSpectrumOrFail)(draft);
|
|
110
|
+
const index = activeSpectrum.index;
|
|
111
|
+
const { size } = action.payload;
|
|
112
|
+
const { data: { x, re, im }, filters, info, } = draft.data[index];
|
|
113
|
+
let _data = { data: { x, re, im }, filters, info };
|
|
114
|
+
(0, zeroFilling_1.apply)(_data, size);
|
|
115
|
+
const { im: newIm, re: newRe, x: newX } = _data.data;
|
|
116
|
+
draft.tempData[index].data.x = newX;
|
|
117
|
+
draft.tempData[index].data.im = newIm;
|
|
118
|
+
draft.tempData[index].data.re = newRe;
|
|
119
|
+
draft.xDomain = [newX[0], newX[newX.length - 1]];
|
|
124
120
|
}
|
|
125
121
|
exports.calculateZeroFillingFilter = calculateZeroFillingFilter;
|
|
126
122
|
function applyFFTFilter(draft) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
123
|
+
const activeSpectrum = (0, getActiveSpectrumOrFail_1.getActiveSpectrumOrFail)(draft);
|
|
124
|
+
const { index } = activeSpectrum;
|
|
125
|
+
//apply filter into the spectrum
|
|
126
|
+
FiltersManager.applyFilter(draft.data[index], [
|
|
127
|
+
{ name: Filters.fft.id, options: {} },
|
|
128
|
+
]);
|
|
129
|
+
(0, ToolsActions_1.resetSelectedTool)(draft);
|
|
130
|
+
(0, PreferencesActions_1.changeSpectrumVerticalAlignment)(draft, { align: 'bottom' });
|
|
131
|
+
(0, DomainActions_1.setDomain)(draft, { yDomain: { isChanged: true } });
|
|
132
|
+
(0, DomainActions_1.setMode)(draft);
|
|
138
133
|
}
|
|
139
134
|
exports.applyFFTFilter = applyFFTFilter;
|
|
140
135
|
function applyManualPhaseCorrectionFilter(draft, filterOptions) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
136
|
+
const activeSpectrum = (0, getActiveSpectrumOrFail_1.getActiveSpectrumOrFail)(draft);
|
|
137
|
+
const { index } = activeSpectrum;
|
|
138
|
+
const { ph0, ph1 } = filterOptions;
|
|
139
|
+
FiltersManager.applyFilter(draft.data[index], [
|
|
140
|
+
{ name: Filters.phaseCorrection.id, options: { ph0, ph1 } },
|
|
141
|
+
]);
|
|
142
|
+
(0, ToolsActions_1.resetSelectedTool)(draft);
|
|
143
|
+
draft.tempData = null;
|
|
144
|
+
(0, DomainActions_1.setDomain)(draft);
|
|
151
145
|
}
|
|
152
146
|
exports.applyManualPhaseCorrectionFilter = applyManualPhaseCorrectionFilter;
|
|
153
147
|
function applyAbsoluteFilter(draft) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
148
|
+
const activeSpectrum = (0, getActiveSpectrumOrFail_1.getActiveSpectrumOrFail)(draft);
|
|
149
|
+
const { index } = activeSpectrum;
|
|
150
|
+
FiltersManager.applyFilter(draft.data[index], [
|
|
151
|
+
{ name: Filters.absolute.id, options: {} },
|
|
152
|
+
]);
|
|
153
|
+
(0, ToolsActions_1.resetSelectedTool)(draft);
|
|
154
|
+
draft.tempData = null;
|
|
155
|
+
(0, DomainActions_1.setDomain)(draft);
|
|
163
156
|
}
|
|
164
157
|
exports.applyAbsoluteFilter = applyAbsoluteFilter;
|
|
165
158
|
function applyAutoPhaseCorrectionFilter(draft) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
159
|
+
const activeSpectrum = (0, getActiveSpectrumOrFail_1.getActiveSpectrumOrFail)(draft);
|
|
160
|
+
const { index } = activeSpectrum;
|
|
161
|
+
const { ph0, ph1 } = (0, autoPhaseCorrection_1.apply)(draft.data[index]);
|
|
162
|
+
FiltersManager.applyFilter(draft.data[index], [
|
|
163
|
+
{ name: Filters.phaseCorrection.id, options: { ph0, ph1 } },
|
|
164
|
+
]);
|
|
165
|
+
(0, ToolsActions_1.resetSelectedTool)(draft);
|
|
166
|
+
draft.tempData = null;
|
|
167
|
+
(0, DomainActions_1.setDomain)(draft);
|
|
176
168
|
}
|
|
177
169
|
exports.applyAutoPhaseCorrectionFilter = applyAutoPhaseCorrectionFilter;
|
|
178
170
|
function calculateBaseLineCorrection(draft, action) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
let _data = { data: { x, re, im }, info };
|
|
191
|
-
(0, baselineCorrection_1.apply)(_data, {
|
|
192
|
-
zones,
|
|
193
|
-
...filterOptions,
|
|
194
|
-
});
|
|
195
|
-
const { im: newIm, re: newRe } = _data.data;
|
|
196
|
-
draft.tempData[index].data.im = newIm;
|
|
197
|
-
draft.tempData[index].data.re = newRe;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
exports.calculateBaseLineCorrection = calculateBaseLineCorrection;
|
|
202
|
-
function calculateManualPhaseCorrection(draft, filterOptions) {
|
|
203
|
-
if (draft.activeSpectrum) {
|
|
204
|
-
const { index } = draft.activeSpectrum;
|
|
205
|
-
const { data: { x, re, im }, info, } = draft.data[index];
|
|
206
|
-
const { ph0, ph1 } = filterOptions;
|
|
171
|
+
const activeSpectrum = (0, getActiveSpectrumOrFail_1.getActiveSpectrumOrFail)(draft);
|
|
172
|
+
const { index } = activeSpectrum;
|
|
173
|
+
const { data: { x, re, im }, info, } = draft.data[index];
|
|
174
|
+
// save the baseline options temporary
|
|
175
|
+
draft.toolOptions.data.baselineCorrection = {
|
|
176
|
+
...draft.toolOptions.data.baselineCorrection,
|
|
177
|
+
...(action?.options ? { options: action.options } : {}),
|
|
178
|
+
};
|
|
179
|
+
const { zones, options } = draft.toolOptions.data.baselineCorrection;
|
|
180
|
+
const { livePreview, ...filterOptions } = options;
|
|
181
|
+
if (livePreview) {
|
|
207
182
|
let _data = { data: { x, re, im }, info };
|
|
208
|
-
(0,
|
|
183
|
+
(0, baselineCorrection_1.apply)(_data, {
|
|
184
|
+
zones,
|
|
185
|
+
...filterOptions,
|
|
186
|
+
});
|
|
209
187
|
const { im: newIm, re: newRe } = _data.data;
|
|
210
188
|
draft.tempData[index].data.im = newIm;
|
|
211
189
|
draft.tempData[index].data.re = newRe;
|
|
212
190
|
}
|
|
213
191
|
}
|
|
192
|
+
exports.calculateBaseLineCorrection = calculateBaseLineCorrection;
|
|
193
|
+
function calculateManualPhaseCorrection(draft, filterOptions) {
|
|
194
|
+
const activeSpectrum = (0, getActiveSpectrumOrFail_1.getActiveSpectrumOrFail)(draft);
|
|
195
|
+
const { index } = activeSpectrum;
|
|
196
|
+
const { data: { x, re, im }, info, } = draft.data[index];
|
|
197
|
+
const { ph0, ph1 } = filterOptions;
|
|
198
|
+
let _data = { data: { x, re, im }, info };
|
|
199
|
+
(0, phaseCorrection_1.apply)(_data, { ph0, ph1 });
|
|
200
|
+
const { im: newIm, re: newRe } = _data.data;
|
|
201
|
+
draft.tempData[index].data.im = newIm;
|
|
202
|
+
draft.tempData[index].data.re = newRe;
|
|
203
|
+
}
|
|
214
204
|
exports.calculateManualPhaseCorrection = calculateManualPhaseCorrection;
|
|
215
205
|
function enableFilter(draft, filterID, checked) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}
|
|
206
|
+
const activeSpectrum = (0, getActiveSpectrumOrFail_1.getActiveSpectrumOrFail)(draft);
|
|
207
|
+
const { index } = activeSpectrum;
|
|
208
|
+
//apply filter into the spectrum
|
|
209
|
+
FiltersManager.enableFilter(draft.data[index], filterID, checked);
|
|
210
|
+
if (draft.data[index].info?.dimension === 1) {
|
|
211
|
+
(0, Spectrum1D_1.updateXShift)(draft.data[index]);
|
|
212
|
+
}
|
|
213
|
+
else if (draft.data[index].info?.dimension === 2) {
|
|
214
|
+
(0, Spectrum2D_1.updateShift)(draft.data[index]);
|
|
215
|
+
}
|
|
216
|
+
(0, ToolsActions_1.resetSelectedTool)(draft);
|
|
217
|
+
(0, DomainActions_1.setDomain)(draft);
|
|
218
|
+
(0, DomainActions_1.setMode)(draft);
|
|
219
|
+
const zoomHistory = (0, ZoomHistoryManager_1.default)(draft.zoom.history, draft.view.spectra.activeTab);
|
|
220
|
+
const zoomValue = zoomHistory.getLast();
|
|
221
|
+
if (zoomValue) {
|
|
222
|
+
draft.xDomain = zoomValue.xDomain;
|
|
223
|
+
draft.yDomain = zoomValue.yDomain;
|
|
235
224
|
}
|
|
236
225
|
}
|
|
237
226
|
exports.enableFilter = enableFilter;
|
|
238
227
|
function deleteFilter(draft, actions) {
|
|
239
228
|
const filterID = actions.payload.id;
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
(0, ToolsActions_1.resetSelectedTool)(draft);
|
|
251
|
-
(0, DomainActions_1.setDomain)(draft);
|
|
252
|
-
(0, DomainActions_1.setMode)(draft);
|
|
229
|
+
const activeSpectrum = (0, getActiveSpectrumOrFail_1.getActiveSpectrumOrFail)(draft);
|
|
230
|
+
const { index } = activeSpectrum;
|
|
231
|
+
//apply filter into the spectrum
|
|
232
|
+
FiltersManager.deleteFilter(draft.data[index], filterID);
|
|
233
|
+
if (draft.data[index].info?.dimension === 1) {
|
|
234
|
+
(0, Spectrum1D_1.updateXShift)(draft.data[index]);
|
|
235
|
+
}
|
|
236
|
+
else if (draft.data[index].info?.dimension === 2) {
|
|
237
|
+
(0, Spectrum2D_1.updateShift)(draft.data[index]);
|
|
253
238
|
}
|
|
239
|
+
(0, ToolsActions_1.resetSelectedTool)(draft);
|
|
240
|
+
(0, DomainActions_1.setDomain)(draft);
|
|
241
|
+
(0, DomainActions_1.setMode)(draft);
|
|
254
242
|
}
|
|
255
243
|
exports.deleteFilter = deleteFilter;
|
|
256
244
|
function deleteSpectraFilter(draft, actions) {
|
|
257
245
|
const filterType = actions.payload.filterType;
|
|
258
|
-
if (draft.activeTab) {
|
|
246
|
+
if (draft.view.spectra.activeTab) {
|
|
259
247
|
for (const datum of draft.data) {
|
|
260
|
-
if ((0, nucleusToString_1.default)(datum?.info?.nucleus) === draft.activeTab) {
|
|
248
|
+
if ((0, nucleusToString_1.default)(datum?.info?.nucleus) === draft.view.spectra.activeTab) {
|
|
261
249
|
const filtersResult = datum.filters?.filter((filter) => filter.name === filterType) || [];
|
|
262
250
|
filtersResult.forEach((filter) => {
|
|
263
251
|
FiltersManager.deleteFilter(datum, filter.id);
|
|
@@ -277,24 +265,23 @@ function deleteSpectraFilter(draft, actions) {
|
|
|
277
265
|
}
|
|
278
266
|
exports.deleteSpectraFilter = deleteSpectraFilter;
|
|
279
267
|
function handleBaseLineCorrectionFilter(draft, action) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
},
|
|
268
|
+
const activeSpectrum = (0, getActiveSpectrumOrFail_1.getActiveSpectrumOrFail)(draft);
|
|
269
|
+
const { index } = activeSpectrum;
|
|
270
|
+
const { zones } = draft.toolOptions.data.baselineCorrection;
|
|
271
|
+
const { livePreview, ...options } = action.options;
|
|
272
|
+
FiltersManager.applyFilter(draft.data[index], [
|
|
273
|
+
{
|
|
274
|
+
name: Filters.baselineCorrection.id,
|
|
275
|
+
options: {
|
|
276
|
+
zones,
|
|
277
|
+
...options,
|
|
291
278
|
},
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
279
|
+
},
|
|
280
|
+
]);
|
|
281
|
+
const xDomainSnapshot = draft.xDomain.slice();
|
|
282
|
+
(0, ToolsActions_1.resetSelectedTool)(draft);
|
|
283
|
+
(0, DomainActions_1.setDomain)(draft);
|
|
284
|
+
draft.xDomain = xDomainSnapshot;
|
|
298
285
|
}
|
|
299
286
|
exports.handleBaseLineCorrectionFilter = handleBaseLineCorrectionFilter;
|
|
300
287
|
/**
|
|
@@ -310,48 +297,46 @@ function resetSpectrumByFilter(draft, options) {
|
|
|
310
297
|
const { updateDomain = true, rollback = false, searchBy = 'id', applyFilter = false, // the filter that we rollback and return the affect data for the selected spectrum
|
|
311
298
|
filterId, } = options || {};
|
|
312
299
|
let currentDatum = null;
|
|
313
|
-
const currentActiveSpectrum = draft
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
FiltersManager.applyFilter(newDatum, [{ name, options }]);
|
|
335
|
-
}
|
|
336
|
-
currentDatum = { datum: newDatum, index };
|
|
300
|
+
const currentActiveSpectrum = (0, getActiveSpectrumOrFail_1.getActiveSpectrumOrFail)(draft);
|
|
301
|
+
const index = currentActiveSpectrum.index;
|
|
302
|
+
const datum = draft.data[index];
|
|
303
|
+
if (filterId && draft.toolOptions.data.activeFilterID !== filterId) {
|
|
304
|
+
const filterIndex = datum.filters.findIndex((f) => f[searchBy] === filterId);
|
|
305
|
+
let filters = [];
|
|
306
|
+
if (filterIndex !== -1) {
|
|
307
|
+
filters = datum.filters.slice(0, rollback ? filterIndex : filterIndex + 1);
|
|
308
|
+
if (filters.length >= 1) {
|
|
309
|
+
draft.toolOptions.data.activeFilterID =
|
|
310
|
+
datum.filters[rollback ? filterIndex - 1 : filterIndex]?.id;
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
draft.toolOptions.data.activeFilterID = null;
|
|
314
|
+
}
|
|
315
|
+
FiltersManager.reapplyFilters(datum, filters);
|
|
316
|
+
if (applyFilter) {
|
|
317
|
+
const { name, value: options } = datum.filters[filterIndex];
|
|
318
|
+
const newDatum = (0, immer_1.current)(draft).data[index];
|
|
319
|
+
if (newDatum.info?.dimension === 1) {
|
|
320
|
+
FiltersManager.applyFilter(newDatum, [{ name, options }]);
|
|
337
321
|
}
|
|
322
|
+
currentDatum = { datum: newDatum, index };
|
|
338
323
|
}
|
|
339
324
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
//close filter snapshot mode and replay all enabled filters
|
|
328
|
+
draft.toolOptions.data.activeFilterID = null;
|
|
329
|
+
FiltersManager.reapplyFilters(datum);
|
|
330
|
+
}
|
|
331
|
+
if (datum.info?.dimension === 1) {
|
|
332
|
+
(0, Spectrum1D_1.updateXShift)(datum);
|
|
333
|
+
}
|
|
334
|
+
else if (datum.info?.dimension === 2) {
|
|
335
|
+
(0, Spectrum2D_1.updateShift)(datum);
|
|
336
|
+
}
|
|
337
|
+
if (updateDomain) {
|
|
338
|
+
(0, DomainActions_1.setDomain)(draft);
|
|
339
|
+
(0, DomainActions_1.setMode)(draft);
|
|
355
340
|
}
|
|
356
341
|
if (applyFilter) {
|
|
357
342
|
return currentDatum;
|
|
@@ -364,7 +349,7 @@ function filterSnapshotHandler(draft, action) {
|
|
|
364
349
|
}
|
|
365
350
|
exports.filterSnapshotHandler = filterSnapshotHandler;
|
|
366
351
|
function handleMultipleSpectraFilter(draft, action) {
|
|
367
|
-
const spectra = (0, getSpectraByNucleus_1.getSpectraByNucleus)(draft.activeTab, draft.data);
|
|
352
|
+
const spectra = (0, getSpectraByNucleus_1.getSpectraByNucleus)(draft.view.spectra.activeTab, draft.data);
|
|
368
353
|
if (spectra && spectra.length > 0 && Array.isArray(action.payload)) {
|
|
369
354
|
const exclusions = spectra[0].filters.find((f) => f.name === Filters.exclusionZones.id)
|
|
370
355
|
?.value || [];
|
|
@@ -388,12 +373,14 @@ function handleAddExclusionZone(draft, action) {
|
|
|
388
373
|
const { from: startX, to: endX } = action.payload;
|
|
389
374
|
const range = (0, getRange_1.default)(draft, { startX, endX });
|
|
390
375
|
let spectra;
|
|
391
|
-
|
|
392
|
-
|
|
376
|
+
// todo: refactor this
|
|
377
|
+
const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
|
|
378
|
+
if (activeSpectrum?.id) {
|
|
379
|
+
const index = activeSpectrum?.index;
|
|
393
380
|
spectra = [draft.data[index]];
|
|
394
381
|
}
|
|
395
382
|
else {
|
|
396
|
-
spectra = (0, getSpectraByNucleus_1.getSpectraByNucleus)(draft.activeTab, draft.data);
|
|
383
|
+
spectra = (0, getSpectraByNucleus_1.getSpectraByNucleus)(draft.view.spectra.activeTab, draft.data);
|
|
397
384
|
}
|
|
398
385
|
for (const spectrum of spectra) {
|
|
399
386
|
FiltersManager.applyFilter(spectrum, [
|
|
@@ -430,7 +417,7 @@ function handleDeleteExclusionZone(draft, action) {
|
|
|
430
417
|
}
|
|
431
418
|
else {
|
|
432
419
|
// remove all exclusive zone that have the same range in all spectra
|
|
433
|
-
const data = (0, getSpectraByNucleus_1.getSpectraByNucleus)(draft.activeTab, draft.data);
|
|
420
|
+
const data = (0, getSpectraByNucleus_1.getSpectraByNucleus)(draft.view.spectra.activeTab, draft.data);
|
|
434
421
|
for (const datum of data) {
|
|
435
422
|
for (const filter of datum.filters) {
|
|
436
423
|
if (filter.name === Filters.exclusionZones.id) {
|
|
@@ -459,7 +446,8 @@ function checkFilterHasTempData(selectedToolId) {
|
|
|
459
446
|
].includes(selectedToolId);
|
|
460
447
|
}
|
|
461
448
|
function setFilterChanges(draft, selectedFilterID) {
|
|
462
|
-
const
|
|
449
|
+
const activeSpectrum = (0, getActiveSpectrumOrFail_1.getActiveSpectrumOrFail)(draft);
|
|
450
|
+
const activeSpectrumId = activeSpectrum.id;
|
|
463
451
|
// 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
|
|
464
452
|
if (checkFilterHasTempData(selectedFilterID)) {
|
|
465
453
|
//return back the spectra data to point of time before applying a specific filter
|
|
@@ -491,14 +479,12 @@ function setFilterChanges(draft, selectedFilterID) {
|
|
|
491
479
|
break;
|
|
492
480
|
}
|
|
493
481
|
case ToolTypes_1.options.baselineCorrection.id: {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
baselineCorrectionFilter
|
|
499
|
-
|
|
500
|
-
: [];
|
|
501
|
-
}
|
|
482
|
+
const baselineCorrectionFilter = (0, immer_1.current)(draft).data[activeSpectrum.index].filters.find((filter) => filter.name === ToolTypes_1.options.baselineCorrection.id);
|
|
483
|
+
if (baselineCorrectionFilter) {
|
|
484
|
+
draft.toolOptions.data.baselineCorrection.zones =
|
|
485
|
+
baselineCorrectionFilter
|
|
486
|
+
? baselineCorrectionFilter.value.zones
|
|
487
|
+
: [];
|
|
502
488
|
}
|
|
503
489
|
break;
|
|
504
490
|
}
|
|
@@ -12,7 +12,8 @@ const SumManager_1 = require("../../../data/data1d/Spectrum1D/SumManager");
|
|
|
12
12
|
const getRange_1 = __importDefault(require("../helper/getRange"));
|
|
13
13
|
const DomainActions_1 = require("./DomainActions");
|
|
14
14
|
function handleChangeIntegralSum(draft, options) {
|
|
15
|
-
const { data,
|
|
15
|
+
const { data, view: { spectra: { activeTab: nucleus }, }, } = draft;
|
|
16
|
+
const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
|
|
16
17
|
if (activeSpectrum?.id) {
|
|
17
18
|
const { index } = activeSpectrum;
|
|
18
19
|
const datum = data[index];
|
|
@@ -23,7 +24,8 @@ function handleChangeIntegralSum(draft, options) {
|
|
|
23
24
|
exports.handleChangeIntegralSum = handleChangeIntegralSum;
|
|
24
25
|
function addIntegral(draft, action) {
|
|
25
26
|
const { startX, endX } = action;
|
|
26
|
-
const { data, molecules, activeTab: nucleus,
|
|
27
|
+
const { data, molecules, view: { spectra: { activeTab: nucleus }, }, } = draft;
|
|
28
|
+
const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
|
|
27
29
|
const [from, to] = (0, getRange_1.default)(draft, { startX, endX });
|
|
28
30
|
if (activeSpectrum?.id) {
|
|
29
31
|
const datum = data[activeSpectrum.index];
|
|
@@ -49,9 +51,10 @@ function addIntegral(draft, action) {
|
|
|
49
51
|
}
|
|
50
52
|
exports.addIntegral = addIntegral;
|
|
51
53
|
function deleteIntegral(draft, action) {
|
|
52
|
-
|
|
54
|
+
const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
|
|
55
|
+
if (activeSpectrum) {
|
|
53
56
|
const state = (0, immer_1.original)(draft);
|
|
54
|
-
const { index } =
|
|
57
|
+
const { index } = activeSpectrum;
|
|
55
58
|
const { integralID } = action;
|
|
56
59
|
const datum = draft.data[index];
|
|
57
60
|
if (integralID == null) {
|
|
@@ -66,10 +69,11 @@ function deleteIntegral(draft, action) {
|
|
|
66
69
|
}
|
|
67
70
|
exports.deleteIntegral = deleteIntegral;
|
|
68
71
|
function changeIntegral(draft, action) {
|
|
72
|
+
const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
|
|
69
73
|
const state = (0, immer_1.original)(draft);
|
|
70
74
|
const integral = action.payload.data;
|
|
71
|
-
if (
|
|
72
|
-
const { index } =
|
|
75
|
+
if (activeSpectrum?.id) {
|
|
76
|
+
const { index } = activeSpectrum;
|
|
73
77
|
const originalDatum = state.data[index];
|
|
74
78
|
const datum = draft.data[index];
|
|
75
79
|
const { x, re } = originalDatum.data;
|
|
@@ -87,9 +91,10 @@ function changeIntegral(draft, action) {
|
|
|
87
91
|
}
|
|
88
92
|
exports.changeIntegral = changeIntegral;
|
|
89
93
|
function handleChangeIntegralsRelativeValue(draft, action) {
|
|
94
|
+
const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
|
|
90
95
|
const data = action.payload.data;
|
|
91
|
-
if (
|
|
92
|
-
const { index } =
|
|
96
|
+
if (activeSpectrum?.id) {
|
|
97
|
+
const { index } = activeSpectrum;
|
|
93
98
|
(0, Spectrum1D_1.changeIntegralsRelative)(draft.data[index], data);
|
|
94
99
|
}
|
|
95
100
|
}
|