nmrium 0.21.0 → 0.22.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/ExclusionZonesAnnotations.js +1 -2
- package/lib/component/1d/Integral.js +1 -6
- package/lib/component/1d/Viewer1D.js +4 -4
- package/lib/component/1d/ranges/RangeIntegral.js +2 -6
- package/lib/component/1d/utilities/scale.d.ts +1 -1
- package/lib/component/1d/utilities/scale.js +7 -6
- package/lib/component/2d/Viewer2D.js +5 -5
- package/lib/component/NMRium.d.ts +2 -0
- package/lib/component/elements/EditableColumn.d.ts +1 -1
- package/lib/component/header/Header.js +3 -7
- package/lib/component/{1d/utilities → hooks}/useIntegralPath.d.ts +0 -0
- package/lib/component/hooks/useIntegralPath.js +53 -0
- package/lib/component/hooks/useToolsFunctions.js +4 -5
- package/lib/component/hooks/useXScale.d.ts +2 -0
- package/lib/component/hooks/useXScale.js +7 -0
- package/lib/component/modal/editRange/forms/validation/EditRangeValidation.js +1 -1
- package/lib/component/modal/editZone/EditPathLengthFormik.d.ts +5 -0
- package/lib/component/modal/editZone/EditPathLengthFormik.js +72 -0
- package/lib/component/modal/editZone/EditZoneModal.d.ts +8 -0
- package/lib/component/modal/editZone/EditZoneModal.js +96 -0
- package/lib/component/modal/editZone/SignalFormTab.d.ts +6 -0
- package/lib/component/modal/editZone/SignalFormTab.js +6 -0
- package/lib/component/modal/editZone/SignalsForm.d.ts +2 -0
- package/lib/component/modal/editZone/SignalsForm.js +62 -0
- package/lib/component/modal/editZone/validation/EditZoneValidation.d.ts +534 -0
- package/lib/component/modal/editZone/validation/EditZoneValidation.js +17 -0
- package/lib/component/modal/editZone/validation/isDefaultPathLength.d.ts +3 -0
- package/lib/component/modal/editZone/validation/isDefaultPathLength.js +7 -0
- package/lib/component/modal/setting/ControllersTabContent.js +1 -1
- package/lib/component/modal/setting/GeneralSettings.d.ts +1 -2
- package/lib/component/modal/setting/GeneralSettings.js +13 -5
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.d.ts +2 -0
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +13 -0
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.d.ts +7 -0
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.js +38 -0
- package/lib/component/panels/Panels.d.ts +1 -1
- package/lib/component/panels/Panels.js +10 -14
- package/lib/component/panels/RangesPanel/RangesPanel.js +2 -2
- package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.js +7 -2
- package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnHeader.js +7 -2
- package/lib/component/panels/SummaryPanel/CorrelationTable/Constants.d.ts +1 -6
- package/lib/component/panels/SummaryPanel/CorrelationTable/Constants.js +1 -7
- package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTable.d.ts +2 -3
- package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTable.js +4 -5
- package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.d.ts +2 -3
- package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +21 -25
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +24 -30
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditPathLength.d.ts +8 -0
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditPathLength.js +89 -0
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/MoveLink.d.ts +1 -1
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/MoveLink.js +1 -1
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +39 -42
- package/lib/component/panels/SummaryPanel/utilities/IsInView.d.ts +6 -0
- package/lib/component/panels/SummaryPanel/utilities/IsInView.js +16 -0
- package/lib/component/panels/SummaryPanel/utilities/Utilities.d.ts +29 -0
- package/lib/component/panels/SummaryPanel/{Utilities.js → utilities/Utilities.js} +155 -19
- package/lib/component/panels/ZonesPanel/TableColumns/ActionsColumn.d.ts +1 -0
- package/lib/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +26 -3
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +12 -4
- package/lib/component/panels/ZonesPanel/ZonesTable.d.ts +3 -2
- package/lib/component/panels/ZonesPanel/ZonesTable.js +5 -2
- package/lib/component/reducer/IgnoreActions.js +2 -1
- package/lib/component/reducer/Reducer.d.ts +9 -23
- package/lib/component/reducer/Reducer.js +7 -8
- package/lib/component/reducer/actions/DatabaseActions.js +1 -1
- package/lib/component/reducer/actions/DomainActions.d.ts +3 -1
- package/lib/component/reducer/actions/DomainActions.js +20 -1
- package/lib/component/reducer/actions/IntegralsActions.js +2 -0
- package/lib/component/reducer/actions/LoadActions.js +22 -1
- package/lib/component/reducer/actions/PreferencesActions.js +0 -2
- package/lib/component/reducer/actions/RangesActions.js +3 -1
- package/lib/component/reducer/actions/SpectrumsActions.js +1 -1
- package/lib/component/reducer/actions/ToolsActions.js +31 -27
- package/lib/component/reducer/actions/ZonesActions.d.ts +3 -1
- package/lib/component/reducer/actions/ZonesActions.js +33 -2
- package/lib/component/reducer/helper/Zoom1DManager.d.ts +17 -21
- package/lib/component/reducer/helper/Zoom1DManager.js +53 -69
- package/lib/component/reducer/preferencesReducer.d.ts +1 -8
- package/lib/component/reducer/preferencesReducer.js +11 -1
- package/lib/component/reducer/types/Types.d.ts +3 -1
- package/lib/component/reducer/types/Types.js +3 -1
- package/lib/data/constants/DefaultPathLengths.d.ts +6 -0
- package/lib/data/constants/DefaultPathLengths.js +8 -0
- package/lib/data/data1d/Spectrum1D/getSpectrumErrorValue.d.ts +2 -0
- package/lib/data/data1d/Spectrum1D/getSpectrumErrorValue.js +4 -0
- package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +7 -19
- package/lib/data/data1d/Spectrum1D/integrals/initiateIntegrals.d.ts +11 -0
- package/lib/data/data1d/Spectrum1D/integrals/initiateIntegrals.js +11 -0
- package/lib/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +2 -21
- package/lib/data/data1d/Spectrum1D/peaks/initiatePeaks.d.ts +9 -0
- package/lib/data/data1d/Spectrum1D/peaks/initiatePeaks.js +7 -0
- package/lib/data/data1d/Spectrum1D/peaks/mapPeaks.d.ts +2 -0
- package/lib/data/data1d/Spectrum1D/peaks/mapPeaks.js +29 -0
- package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +13 -0
- package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.js +14 -0
- package/lib/data/data1d/Spectrum1D/ranges/mapRanges.js +13 -8
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/ExclusionZonesAnnotations.js +1 -2
- package/lib-cjs/component/1d/Integral.js +1 -6
- package/lib-cjs/component/1d/Viewer1D.js +4 -4
- package/lib-cjs/component/1d/ranges/RangeIntegral.js +2 -6
- package/lib-cjs/component/1d/utilities/scale.js +7 -6
- package/lib-cjs/component/2d/Viewer2D.js +4 -4
- package/lib-cjs/component/header/Header.js +3 -7
- package/lib-cjs/component/hooks/useIntegralPath.js +56 -0
- package/lib-cjs/component/hooks/useToolsFunctions.js +4 -5
- package/lib-cjs/component/hooks/useXScale.js +11 -0
- package/lib-cjs/component/modal/editRange/forms/validation/EditRangeValidation.js +1 -1
- package/lib-cjs/component/modal/editZone/EditPathLengthFormik.js +77 -0
- package/lib-cjs/component/modal/editZone/EditZoneModal.js +101 -0
- package/lib-cjs/component/modal/editZone/SignalFormTab.js +11 -0
- package/lib-cjs/component/modal/editZone/SignalsForm.js +67 -0
- package/lib-cjs/component/modal/editZone/validation/EditZoneValidation.js +38 -0
- package/lib-cjs/component/modal/editZone/validation/isDefaultPathLength.js +12 -0
- package/lib-cjs/component/modal/setting/ControllersTabContent.js +1 -1
- package/lib-cjs/component/modal/setting/GeneralSettings.js +12 -4
- package/lib-cjs/component/panels/AutomaticAssignment/AutomaticAssignment.js +18 -0
- package/lib-cjs/component/panels/AutomaticAssignment/AutomaticAssignmentTable.js +43 -0
- package/lib-cjs/component/panels/Panels.js +11 -15
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +2 -2
- package/lib-cjs/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.js +7 -2
- package/lib-cjs/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnHeader.js +7 -2
- package/lib-cjs/component/panels/SummaryPanel/CorrelationTable/Constants.js +1 -8
- package/lib-cjs/component/panels/SummaryPanel/CorrelationTable/CorrelationTable.js +4 -5
- package/lib-cjs/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +21 -25
- package/lib-cjs/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +43 -30
- package/lib-cjs/component/panels/SummaryPanel/CorrelationTable/editLink/EditPathLength.js +94 -0
- package/lib-cjs/component/panels/SummaryPanel/CorrelationTable/editLink/MoveLink.js +1 -1
- package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +38 -41
- package/lib-cjs/component/panels/SummaryPanel/utilities/IsInView.js +18 -0
- package/lib-cjs/component/panels/SummaryPanel/{Utilities.js → utilities/Utilities.js} +157 -19
- package/lib-cjs/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +24 -1
- package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +12 -4
- package/lib-cjs/component/panels/ZonesPanel/ZonesTable.js +5 -2
- package/lib-cjs/component/reducer/IgnoreActions.js +2 -1
- package/lib-cjs/component/reducer/Reducer.js +7 -8
- package/lib-cjs/component/reducer/actions/DatabaseActions.js +2 -2
- package/lib-cjs/component/reducer/actions/DomainActions.js +21 -1
- package/lib-cjs/component/reducer/actions/IntegralsActions.js +2 -0
- package/lib-cjs/component/reducer/actions/LoadActions.js +22 -1
- package/lib-cjs/component/reducer/actions/PreferencesActions.js +0 -2
- package/lib-cjs/component/reducer/actions/RangesActions.js +2 -0
- package/lib-cjs/component/reducer/actions/SpectrumsActions.js +2 -2
- package/lib-cjs/component/reducer/actions/ToolsActions.js +38 -34
- package/lib-cjs/component/reducer/actions/ZonesActions.js +35 -2
- package/lib-cjs/component/reducer/helper/Zoom1DManager.js +55 -73
- package/lib-cjs/component/reducer/preferencesReducer.js +12 -2
- package/lib-cjs/component/reducer/types/Types.js +6 -4
- package/lib-cjs/data/constants/DefaultPathLengths.js +10 -0
- package/lib-cjs/data/data1d/Spectrum1D/getSpectrumErrorValue.js +8 -0
- package/lib-cjs/data/data1d/Spectrum1D/initiateDatum1D.js +7 -19
- package/lib-cjs/data/data1d/Spectrum1D/integrals/initiateIntegrals.js +18 -0
- package/lib-cjs/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +2 -21
- package/lib-cjs/data/data1d/Spectrum1D/peaks/initiatePeaks.js +14 -0
- package/lib-cjs/data/data1d/Spectrum1D/peaks/mapPeaks.js +36 -0
- package/lib-cjs/data/data1d/Spectrum1D/ranges/initiateRanges.js +21 -0
- package/lib-cjs/data/data1d/Spectrum1D/ranges/mapRanges.js +13 -8
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +1 -1
- package/lib/component/1d/utilities/useIntegralPath.js +0 -63
- package/lib/component/panels/SummaryPanel/Utilities.d.ts +0 -25
- package/lib/component/reducer/actions/Zoom.d.ts +0 -16
- package/lib/component/reducer/actions/Zoom.js +0 -92
- package/lib-cjs/component/1d/utilities/useIntegralPath.js +0 -66
- package/lib-cjs/component/reducer/actions/Zoom.js +0 -116
|
@@ -6,14 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.autoPeakPicking = void 0;
|
|
7
7
|
const ml_array_median_1 = __importDefault(require("ml-array-median"));
|
|
8
8
|
const nmr_processing_1 = require("nmr-processing");
|
|
9
|
-
const
|
|
10
|
-
const getShiftX_1 = require("../shift/getShiftX");
|
|
9
|
+
const mapPeaks_1 = require("./mapPeaks");
|
|
11
10
|
function autoPeakPicking(datum1D, options) {
|
|
12
11
|
const { minMaxRatio, maxNumberOfPeaks, noiseFactor, lookNegative, windowFromIndex, windowToIndex, } = options;
|
|
13
12
|
// we calculate the noise but this could be improved
|
|
14
13
|
const noise = (0, ml_array_median_1.default)(datum1D.data.re.map((y) => Math.abs(y)));
|
|
15
14
|
let { re, x } = datum1D.data;
|
|
16
|
-
let { values: currentPeaks = [] } = datum1D.peaks || {};
|
|
17
15
|
if (windowFromIndex !== undefined && windowToIndex !== undefined) {
|
|
18
16
|
x = x.slice(windowFromIndex, windowToIndex);
|
|
19
17
|
re = re.slice(windowFromIndex, windowToIndex);
|
|
@@ -29,23 +27,6 @@ function autoPeakPicking(datum1D, options) {
|
|
|
29
27
|
peaks.sort((a, b) => b.y - a.y);
|
|
30
28
|
if (maxNumberOfPeaks < peaks.length)
|
|
31
29
|
peaks = peaks.slice(0, maxNumberOfPeaks);
|
|
32
|
-
|
|
33
|
-
const error = (x[x.length - 1] - x[0]) / 10000;
|
|
34
|
-
return peaks.reduce((acc, newPeak) => {
|
|
35
|
-
// check if the peak is already exists
|
|
36
|
-
for (const { x } of currentPeaks) {
|
|
37
|
-
if (Math.abs(newPeak.x - x) < error) {
|
|
38
|
-
return acc;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
acc.push({
|
|
42
|
-
id: (0, generateID_1.default)(),
|
|
43
|
-
originalX: newPeak.x - shiftX,
|
|
44
|
-
x: newPeak.x,
|
|
45
|
-
y: newPeak.y,
|
|
46
|
-
width: newPeak.width,
|
|
47
|
-
});
|
|
48
|
-
return acc;
|
|
49
|
-
}, []);
|
|
30
|
+
return (0, mapPeaks_1.mapPeaks)(peaks, datum1D);
|
|
50
31
|
}
|
|
51
32
|
exports.autoPeakPicking = autoPeakPicking;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.initiatePeaks = void 0;
|
|
7
|
+
const merge_1 = __importDefault(require("lodash/merge"));
|
|
8
|
+
const mapPeaks_1 = require("./mapPeaks");
|
|
9
|
+
function initiatePeaks(options, datum) {
|
|
10
|
+
return (0, merge_1.default)({ values: [], options: {} }, options.peaks, {
|
|
11
|
+
values: (0, mapPeaks_1.mapPeaks)(options?.peaks?.values || [], datum),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
exports.initiatePeaks = initiatePeaks;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.mapPeaks = void 0;
|
|
7
|
+
const generateID_1 = __importDefault(require("../../../utilities/generateID"));
|
|
8
|
+
const getSpectrumErrorValue_1 = require("../getSpectrumErrorValue");
|
|
9
|
+
const getShiftX_1 = require("../shift/getShiftX");
|
|
10
|
+
function checkPeak(peak, datum, error) {
|
|
11
|
+
// check if the Peak is already exists
|
|
12
|
+
for (const { x } of datum.peaks?.values || []) {
|
|
13
|
+
if (Math.abs(peak.x - x) < error) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
function mapPeaks(peaks, datum) {
|
|
20
|
+
const shiftX = (0, getShiftX_1.getShiftX)(datum);
|
|
21
|
+
const error = (0, getSpectrumErrorValue_1.getSpectrumErrorValue)(datum);
|
|
22
|
+
return peaks.reduce((acc, newPeak) => {
|
|
23
|
+
// check if the peak is already exists
|
|
24
|
+
if (checkPeak(newPeak, datum, error))
|
|
25
|
+
return acc;
|
|
26
|
+
acc.push({
|
|
27
|
+
id: newPeak?.id || (0, generateID_1.default)(),
|
|
28
|
+
originalX: newPeak.x - shiftX,
|
|
29
|
+
x: newPeak.x,
|
|
30
|
+
y: newPeak.y,
|
|
31
|
+
width: newPeak.width,
|
|
32
|
+
});
|
|
33
|
+
return acc;
|
|
34
|
+
}, []);
|
|
35
|
+
}
|
|
36
|
+
exports.mapPeaks = mapPeaks;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.initiateRanges = void 0;
|
|
7
|
+
const merge_1 = __importDefault(require("lodash/merge"));
|
|
8
|
+
const mapRanges_1 = require("./mapRanges");
|
|
9
|
+
function initiateRanges(options, datum) {
|
|
10
|
+
return (0, merge_1.default)({
|
|
11
|
+
values: [],
|
|
12
|
+
options: {
|
|
13
|
+
sum: undefined,
|
|
14
|
+
isSumConstant: true,
|
|
15
|
+
sumAuto: true,
|
|
16
|
+
},
|
|
17
|
+
}, options.ranges, {
|
|
18
|
+
values: (0, mapRanges_1.mapRanges)(options?.ranges?.values || [], datum),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.initiateRanges = initiateRanges;
|
|
@@ -7,19 +7,24 @@ exports.mapRanges = void 0;
|
|
|
7
7
|
const ml_spectra_processing_1 = require("ml-spectra-processing");
|
|
8
8
|
const SignalsKinds_1 = require("../../../constants/SignalsKinds");
|
|
9
9
|
const generateID_1 = __importDefault(require("../../../utilities/generateID"));
|
|
10
|
+
const getSpectrumErrorValue_1 = require("../getSpectrumErrorValue");
|
|
10
11
|
const getShiftX_1 = require("../shift/getShiftX");
|
|
12
|
+
function checkRange(range, datum, error) {
|
|
13
|
+
// check if the range is already exists
|
|
14
|
+
for (const { from, to } of datum.ranges?.values || []) {
|
|
15
|
+
if (Math.abs(range.from - from) < error &&
|
|
16
|
+
Math.abs(range.to - to) < error) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
11
21
|
function mapRanges(ranges, datum) {
|
|
12
22
|
const { x, re } = datum.data;
|
|
13
23
|
const shiftX = (0, getShiftX_1.getShiftX)(datum);
|
|
14
|
-
const error = (
|
|
24
|
+
const error = (0, getSpectrumErrorValue_1.getSpectrumErrorValue)(datum);
|
|
15
25
|
return ranges.reduce((acc, newRange) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (Math.abs(newRange.from - from) < error &&
|
|
19
|
-
Math.abs(newRange.to - to) < error) {
|
|
20
|
-
return acc;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
26
|
+
if (checkRange(newRange, datum, error))
|
|
27
|
+
return acc;
|
|
23
28
|
const absolute = (0, ml_spectra_processing_1.xyIntegration)({ x, y: re }, { from: newRange.from, to: newRange.to, reverse: true });
|
|
24
29
|
const signals = newRange.signals.map((signal) => {
|
|
25
30
|
const { kind = null, id, ...resSignal } = signal;
|
package/lib-cjs/versionInfo.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nmrium",
|
|
3
3
|
"description": "React component to display and process nuclear magnetic resonance (NMR) spectra.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.22.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib-cjs/component/NMRium.js",
|
|
7
7
|
"module": "lib/component/NMRium.js",
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { xyIntegral, xyReduce } from 'ml-spectra-processing';
|
|
2
|
-
import { useMemo } from 'react';
|
|
3
|
-
import { useChartData } from '../../context/ChartContext';
|
|
4
|
-
import { useScale } from '../../context/ScaleContext';
|
|
5
|
-
import { PathBuilder } from '../../utility/PathBuilder';
|
|
6
|
-
import { getYScale, reScaleY } from './scale';
|
|
7
|
-
export default function useIntegralPath(integralOptions) {
|
|
8
|
-
const { xDomain, height, yDomain, margin, verticalAlign, data, activeSpectrum, zoom, } = useChartData();
|
|
9
|
-
const { scaleX } = useScale();
|
|
10
|
-
const scaleY = useMemo(() => {
|
|
11
|
-
const scale = zoom.integral.scales[activeSpectrum?.id || ''];
|
|
12
|
-
const scaledYDomain = reScaleY(scale === undefined ? 1 : scale < 0.1 ? 0.05 : scale, {
|
|
13
|
-
domain: [yDomain[0], yDomain[1] / 20],
|
|
14
|
-
height,
|
|
15
|
-
margin,
|
|
16
|
-
});
|
|
17
|
-
return getYScale({
|
|
18
|
-
height,
|
|
19
|
-
margin,
|
|
20
|
-
verticalAlign,
|
|
21
|
-
yDomain: scaledYDomain,
|
|
22
|
-
});
|
|
23
|
-
}, [
|
|
24
|
-
activeSpectrum?.id,
|
|
25
|
-
height,
|
|
26
|
-
margin,
|
|
27
|
-
verticalAlign,
|
|
28
|
-
yDomain,
|
|
29
|
-
zoom.integral.scales,
|
|
30
|
-
]);
|
|
31
|
-
const integral = useMemo(() => {
|
|
32
|
-
if (activeSpectrum) {
|
|
33
|
-
const { x, re } = data[activeSpectrum?.index].data;
|
|
34
|
-
const { from, to } = integralOptions;
|
|
35
|
-
return xyIntegral({ x, y: re }, {
|
|
36
|
-
from,
|
|
37
|
-
to,
|
|
38
|
-
reverse: true,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return { x: [], y: [] };
|
|
42
|
-
}, [activeSpectrum, data, integralOptions]);
|
|
43
|
-
const paths = useMemo(() => {
|
|
44
|
-
if (integral && scaleX) {
|
|
45
|
-
const xySeries = xyReduce(integral, {
|
|
46
|
-
from: xDomain[0],
|
|
47
|
-
to: xDomain[1],
|
|
48
|
-
nbPoints: 200,
|
|
49
|
-
optimize: true,
|
|
50
|
-
});
|
|
51
|
-
const pathBuilder = new PathBuilder();
|
|
52
|
-
pathBuilder.moveTo(scaleX()(xySeries.x[0]), scaleY(xySeries.y[0]));
|
|
53
|
-
for (let i = 1; i < xySeries.x.length; i++) {
|
|
54
|
-
pathBuilder.lineTo(scaleX()(xySeries.x[i]), scaleY(xySeries.y[i]));
|
|
55
|
-
}
|
|
56
|
-
return pathBuilder.toString();
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
return '';
|
|
60
|
-
}
|
|
61
|
-
}, [integral, scaleX, scaleY, xDomain]);
|
|
62
|
-
return paths;
|
|
63
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Link, Correlation } from 'nmr-correlation';
|
|
2
|
-
import { Datum2D } from '../../../data/types/data2d';
|
|
3
|
-
declare function getAtomType(nucleus: string): string;
|
|
4
|
-
declare function getLabelColor(correlationData: any, correlation: any): string | null;
|
|
5
|
-
declare function findSignalMatch1D(spectrum: Datum2D, link: Link, factor: number, xDomain0: number, xDomain1: number): boolean;
|
|
6
|
-
declare function findSignalMatch2D(spectrum: Datum2D, link: Link, factor: number, xDomain0: number, xDomain1: number, yDomain0: number, yDomain1: number): boolean;
|
|
7
|
-
declare function getAbbreviation(link: Link): string;
|
|
8
|
-
declare function buildNewLink1D(link: any): Link;
|
|
9
|
-
declare function buildNewLink2D(link: Link, axis: 'x' | 'y'): Link;
|
|
10
|
-
declare function cloneCorrelationAndEditLink(correlation: Correlation, link: Link, axis: 'x' | 'y', action: 'add' | 'remove' | 'unmove'): Correlation;
|
|
11
|
-
declare function getEditedCorrelations({ correlationDim1, correlationDim2, selectedCorrelationValueDim1, selectedCorrelationValueDim2, action, link, correlations, }: {
|
|
12
|
-
correlationDim1: any;
|
|
13
|
-
correlationDim2: any;
|
|
14
|
-
selectedCorrelationValueDim1: any;
|
|
15
|
-
selectedCorrelationValueDim2: any;
|
|
16
|
-
action: any;
|
|
17
|
-
link: any;
|
|
18
|
-
correlations: any;
|
|
19
|
-
}): {
|
|
20
|
-
editedCorrelations: Correlation[];
|
|
21
|
-
buildCorrelationDataOptions: {
|
|
22
|
-
skipDataUpdate?: boolean | undefined;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
export { buildNewLink1D, buildNewLink2D, cloneCorrelationAndEditLink, findSignalMatch1D, findSignalMatch2D, getAbbreviation, getAtomType, getEditedCorrelations, getLabelColor, };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Draft } from 'immer';
|
|
2
|
-
import { State } from '../Reducer';
|
|
3
|
-
export declare const ZoomType: {
|
|
4
|
-
HORIZONTAL: string;
|
|
5
|
-
VERTICAL: string;
|
|
6
|
-
STEP_HORIZONTAL: string;
|
|
7
|
-
FULL: string;
|
|
8
|
-
};
|
|
9
|
-
export declare function wheel(deltaY: any, deltaMode: any, draft: Draft<State>, id?: string | null): void;
|
|
10
|
-
declare function setZoom(draft: Draft<State>, options?: {
|
|
11
|
-
scale?: number;
|
|
12
|
-
spectrumID?: string;
|
|
13
|
-
shareYDomain?: boolean;
|
|
14
|
-
}): void;
|
|
15
|
-
declare function setZoom1D(draft: any, height: any, margin: any, index: any, defaultScale?: number): void;
|
|
16
|
-
export { setZoom, setZoom1D };
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { zoomIdentity, scaleLinear } from 'd3';
|
|
2
|
-
import Zoom1DManager, { setAllScales } from '../helper/Zoom1DManager';
|
|
3
|
-
export const ZoomType = {
|
|
4
|
-
HORIZONTAL: 'HORIZONTAL',
|
|
5
|
-
VERTICAL: 'VERTICAL',
|
|
6
|
-
STEP_HORIZONTAL: 'STEP_HORIZONTAL',
|
|
7
|
-
FULL: 'FULL',
|
|
8
|
-
};
|
|
9
|
-
export function wheel(deltaY, deltaMode, draft, id = null) {
|
|
10
|
-
if (draft.activeSpectrum?.id || id) {
|
|
11
|
-
Zoom1DManager(draft.zoom.spectra).wheel(deltaY, id || draft.activeSpectrum?.id);
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
const zoomManager = Zoom1DManager(draft.zoom.spectra);
|
|
15
|
-
draft.data.forEach((datum) => {
|
|
16
|
-
if (datum.info.dimension === 1 &&
|
|
17
|
-
draft.activeTab === datum.info.nucleus) {
|
|
18
|
-
zoomManager.wheel(deltaY, datum.id);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function setZoom(draft, options = {}) {
|
|
24
|
-
const { height, margin, activeSpectrum } = draft;
|
|
25
|
-
const { scale = null, spectrumID = null } = options;
|
|
26
|
-
if (scale && !spectrumID) {
|
|
27
|
-
setAllScales(draft.zoom.spectra, scale);
|
|
28
|
-
}
|
|
29
|
-
const zoomManager = Zoom1DManager(draft.zoom.spectra);
|
|
30
|
-
if (activeSpectrum === null && spectrumID === null) {
|
|
31
|
-
const { shareYDomain, yDomain, yDomains } = draft.originDomain;
|
|
32
|
-
draft.yDomains = Object.keys(draft.yDomains).reduce((acc, id) => {
|
|
33
|
-
const scale = zoomManager.getScale(id);
|
|
34
|
-
const _scale = scaleLinear(shareYDomain ? yDomain : yDomains[id], [
|
|
35
|
-
height - margin.bottom,
|
|
36
|
-
margin.top,
|
|
37
|
-
]);
|
|
38
|
-
const [min, max] = shareYDomain ? yDomain : yDomains[id];
|
|
39
|
-
const maxPoint = Math.max(Math.abs(max), Math.abs(min));
|
|
40
|
-
const scalePoint = maxPoint === max ? 0 : min;
|
|
41
|
-
const t = zoomIdentity
|
|
42
|
-
.translate(0, Math.sign(scalePoint) >= 0 ? _scale(scalePoint) : _scale(scalePoint))
|
|
43
|
-
.scale(scale)
|
|
44
|
-
.translate(0, -_scale(0));
|
|
45
|
-
const newYDomain = t.rescaleY(_scale).domain();
|
|
46
|
-
acc[id] = newYDomain;
|
|
47
|
-
return acc;
|
|
48
|
-
}, {});
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
const spectrumId = spectrumID || activeSpectrum?.id;
|
|
52
|
-
if (spectrumId) {
|
|
53
|
-
if (scale) {
|
|
54
|
-
zoomManager.setScale(scale, spectrumId);
|
|
55
|
-
}
|
|
56
|
-
const scaleFactor = scale ? scale : zoomManager.getScale(spectrumId);
|
|
57
|
-
const _scale = scaleLinear(draft.originDomain.yDomains[spectrumId], [
|
|
58
|
-
height - margin.bottom,
|
|
59
|
-
margin.top,
|
|
60
|
-
]);
|
|
61
|
-
const t = zoomIdentity
|
|
62
|
-
.translate(0, _scale(0))
|
|
63
|
-
.scale(scaleFactor)
|
|
64
|
-
.translate(0, -_scale(0));
|
|
65
|
-
const yDomain = t.rescaleY(_scale).domain();
|
|
66
|
-
draft.yDomains = {
|
|
67
|
-
...draft.yDomains,
|
|
68
|
-
[spectrumId]: yDomain,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function setZoom1D(draft, height, margin, index, defaultScale) {
|
|
74
|
-
const { originDomain, tabActiveSpectrum, activeTab } = draft;
|
|
75
|
-
const { id } = tabActiveSpectrum[activeTab.split(',')[index]];
|
|
76
|
-
const { setScale, getScale } = Zoom1DManager(draft.zoom.spectra);
|
|
77
|
-
if (defaultScale) {
|
|
78
|
-
setScale(defaultScale, id);
|
|
79
|
-
}
|
|
80
|
-
const scale = getScale(id);
|
|
81
|
-
const _scale = scaleLinear(originDomain.yDomains[id], [
|
|
82
|
-
height - margin,
|
|
83
|
-
margin,
|
|
84
|
-
]);
|
|
85
|
-
const t = zoomIdentity
|
|
86
|
-
.translate(0, _scale(0))
|
|
87
|
-
.scale(scale)
|
|
88
|
-
.translate(0, -_scale(0));
|
|
89
|
-
let yDomain = t.rescaleY(_scale).domain();
|
|
90
|
-
draft.yDomains[id] = yDomain;
|
|
91
|
-
}
|
|
92
|
-
export { setZoom, setZoom1D };
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ml_spectra_processing_1 = require("ml-spectra-processing");
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const ChartContext_1 = require("../../context/ChartContext");
|
|
6
|
-
const ScaleContext_1 = require("../../context/ScaleContext");
|
|
7
|
-
const PathBuilder_1 = require("../../utility/PathBuilder");
|
|
8
|
-
const scale_1 = require("./scale");
|
|
9
|
-
function useIntegralPath(integralOptions) {
|
|
10
|
-
const { xDomain, height, yDomain, margin, verticalAlign, data, activeSpectrum, zoom, } = (0, ChartContext_1.useChartData)();
|
|
11
|
-
const { scaleX } = (0, ScaleContext_1.useScale)();
|
|
12
|
-
const scaleY = (0, react_1.useMemo)(() => {
|
|
13
|
-
const scale = zoom.integral.scales[activeSpectrum?.id || ''];
|
|
14
|
-
const scaledYDomain = (0, scale_1.reScaleY)(scale === undefined ? 1 : scale < 0.1 ? 0.05 : scale, {
|
|
15
|
-
domain: [yDomain[0], yDomain[1] / 20],
|
|
16
|
-
height,
|
|
17
|
-
margin,
|
|
18
|
-
});
|
|
19
|
-
return (0, scale_1.getYScale)({
|
|
20
|
-
height,
|
|
21
|
-
margin,
|
|
22
|
-
verticalAlign,
|
|
23
|
-
yDomain: scaledYDomain,
|
|
24
|
-
});
|
|
25
|
-
}, [
|
|
26
|
-
activeSpectrum?.id,
|
|
27
|
-
height,
|
|
28
|
-
margin,
|
|
29
|
-
verticalAlign,
|
|
30
|
-
yDomain,
|
|
31
|
-
zoom.integral.scales,
|
|
32
|
-
]);
|
|
33
|
-
const integral = (0, react_1.useMemo)(() => {
|
|
34
|
-
if (activeSpectrum) {
|
|
35
|
-
const { x, re } = data[activeSpectrum?.index].data;
|
|
36
|
-
const { from, to } = integralOptions;
|
|
37
|
-
return (0, ml_spectra_processing_1.xyIntegral)({ x, y: re }, {
|
|
38
|
-
from,
|
|
39
|
-
to,
|
|
40
|
-
reverse: true,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return { x: [], y: [] };
|
|
44
|
-
}, [activeSpectrum, data, integralOptions]);
|
|
45
|
-
const paths = (0, react_1.useMemo)(() => {
|
|
46
|
-
if (integral && scaleX) {
|
|
47
|
-
const xySeries = (0, ml_spectra_processing_1.xyReduce)(integral, {
|
|
48
|
-
from: xDomain[0],
|
|
49
|
-
to: xDomain[1],
|
|
50
|
-
nbPoints: 200,
|
|
51
|
-
optimize: true,
|
|
52
|
-
});
|
|
53
|
-
const pathBuilder = new PathBuilder_1.PathBuilder();
|
|
54
|
-
pathBuilder.moveTo(scaleX()(xySeries.x[0]), scaleY(xySeries.y[0]));
|
|
55
|
-
for (let i = 1; i < xySeries.x.length; i++) {
|
|
56
|
-
pathBuilder.lineTo(scaleX()(xySeries.x[i]), scaleY(xySeries.y[i]));
|
|
57
|
-
}
|
|
58
|
-
return pathBuilder.toString();
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
return '';
|
|
62
|
-
}
|
|
63
|
-
}, [integral, scaleX, scaleY, xDomain]);
|
|
64
|
-
return paths;
|
|
65
|
-
}
|
|
66
|
-
exports.default = useIntegralPath;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.setZoom1D = exports.setZoom = exports.wheel = exports.ZoomType = void 0;
|
|
23
|
-
const d3_1 = require("d3");
|
|
24
|
-
const Zoom1DManager_1 = __importStar(require("../helper/Zoom1DManager"));
|
|
25
|
-
exports.ZoomType = {
|
|
26
|
-
HORIZONTAL: 'HORIZONTAL',
|
|
27
|
-
VERTICAL: 'VERTICAL',
|
|
28
|
-
STEP_HORIZONTAL: 'STEP_HORIZONTAL',
|
|
29
|
-
FULL: 'FULL',
|
|
30
|
-
};
|
|
31
|
-
function wheel(deltaY, deltaMode, draft, id = null) {
|
|
32
|
-
if (draft.activeSpectrum?.id || id) {
|
|
33
|
-
(0, Zoom1DManager_1.default)(draft.zoom.spectra).wheel(deltaY, id || draft.activeSpectrum?.id);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
const zoomManager = (0, Zoom1DManager_1.default)(draft.zoom.spectra);
|
|
37
|
-
draft.data.forEach((datum) => {
|
|
38
|
-
if (datum.info.dimension === 1 &&
|
|
39
|
-
draft.activeTab === datum.info.nucleus) {
|
|
40
|
-
zoomManager.wheel(deltaY, datum.id);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.wheel = wheel;
|
|
46
|
-
function setZoom(draft, options = {}) {
|
|
47
|
-
const { height, margin, activeSpectrum } = draft;
|
|
48
|
-
const { scale = null, spectrumID = null } = options;
|
|
49
|
-
if (scale && !spectrumID) {
|
|
50
|
-
(0, Zoom1DManager_1.setAllScales)(draft.zoom.spectra, scale);
|
|
51
|
-
}
|
|
52
|
-
const zoomManager = (0, Zoom1DManager_1.default)(draft.zoom.spectra);
|
|
53
|
-
if (activeSpectrum === null && spectrumID === null) {
|
|
54
|
-
const { shareYDomain, yDomain, yDomains } = draft.originDomain;
|
|
55
|
-
draft.yDomains = Object.keys(draft.yDomains).reduce((acc, id) => {
|
|
56
|
-
const scale = zoomManager.getScale(id);
|
|
57
|
-
const _scale = (0, d3_1.scaleLinear)(shareYDomain ? yDomain : yDomains[id], [
|
|
58
|
-
height - margin.bottom,
|
|
59
|
-
margin.top,
|
|
60
|
-
]);
|
|
61
|
-
const [min, max] = shareYDomain ? yDomain : yDomains[id];
|
|
62
|
-
const maxPoint = Math.max(Math.abs(max), Math.abs(min));
|
|
63
|
-
const scalePoint = maxPoint === max ? 0 : min;
|
|
64
|
-
const t = d3_1.zoomIdentity
|
|
65
|
-
.translate(0, Math.sign(scalePoint) >= 0 ? _scale(scalePoint) : _scale(scalePoint))
|
|
66
|
-
.scale(scale)
|
|
67
|
-
.translate(0, -_scale(0));
|
|
68
|
-
const newYDomain = t.rescaleY(_scale).domain();
|
|
69
|
-
acc[id] = newYDomain;
|
|
70
|
-
return acc;
|
|
71
|
-
}, {});
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
const spectrumId = spectrumID || activeSpectrum?.id;
|
|
75
|
-
if (spectrumId) {
|
|
76
|
-
if (scale) {
|
|
77
|
-
zoomManager.setScale(scale, spectrumId);
|
|
78
|
-
}
|
|
79
|
-
const scaleFactor = scale ? scale : zoomManager.getScale(spectrumId);
|
|
80
|
-
const _scale = (0, d3_1.scaleLinear)(draft.originDomain.yDomains[spectrumId], [
|
|
81
|
-
height - margin.bottom,
|
|
82
|
-
margin.top,
|
|
83
|
-
]);
|
|
84
|
-
const t = d3_1.zoomIdentity
|
|
85
|
-
.translate(0, _scale(0))
|
|
86
|
-
.scale(scaleFactor)
|
|
87
|
-
.translate(0, -_scale(0));
|
|
88
|
-
const yDomain = t.rescaleY(_scale).domain();
|
|
89
|
-
draft.yDomains = {
|
|
90
|
-
...draft.yDomains,
|
|
91
|
-
[spectrumId]: yDomain,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.setZoom = setZoom;
|
|
97
|
-
function setZoom1D(draft, height, margin, index, defaultScale) {
|
|
98
|
-
const { originDomain, tabActiveSpectrum, activeTab } = draft;
|
|
99
|
-
const { id } = tabActiveSpectrum[activeTab.split(',')[index]];
|
|
100
|
-
const { setScale, getScale } = (0, Zoom1DManager_1.default)(draft.zoom.spectra);
|
|
101
|
-
if (defaultScale) {
|
|
102
|
-
setScale(defaultScale, id);
|
|
103
|
-
}
|
|
104
|
-
const scale = getScale(id);
|
|
105
|
-
const _scale = (0, d3_1.scaleLinear)(originDomain.yDomains[id], [
|
|
106
|
-
height - margin,
|
|
107
|
-
margin,
|
|
108
|
-
]);
|
|
109
|
-
const t = d3_1.zoomIdentity
|
|
110
|
-
.translate(0, _scale(0))
|
|
111
|
-
.scale(scale)
|
|
112
|
-
.translate(0, -_scale(0));
|
|
113
|
-
let yDomain = t.rescaleY(_scale).domain();
|
|
114
|
-
draft.yDomains[id] = yDomain;
|
|
115
|
-
}
|
|
116
|
-
exports.setZoom1D = setZoom1D;
|