nmrium 0.19.1 → 0.20.1
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/Chart1D.js +3 -3
- package/lib/component/1d/ExclusionZoneAnnotation.d.ts +11 -0
- package/lib/component/1d/ExclusionZoneAnnotation.js +18 -0
- package/lib/component/1d/ExclusionZonesAnnotations.d.ts +3 -0
- package/lib/component/1d/ExclusionZonesAnnotations.js +28 -0
- package/lib/component/1d/Line.js +11 -23
- package/lib/component/1d/Viewer1D.js +36 -5
- package/lib/component/1d/ranges/Ranges.js +3 -3
- package/lib/component/1d/{BaseLineZones.d.ts → tool/BaseLineZones.d.ts} +0 -0
- package/lib/component/1d/{BaseLineZones.js → tool/BaseLineZones.js} +5 -5
- package/lib/component/1d/utilities/useIntegralPath.js +9 -10
- package/lib/component/2d/Contours.js +12 -11
- package/lib/component/2d/Left1DChart.js +7 -9
- package/lib/component/2d/Top1DChart.js +7 -7
- package/lib/component/2d/tools/slicing/HorizontalSliceChart.js +7 -7
- package/lib/component/2d/tools/slicing/VerticalSliceChart.js +7 -9
- package/lib/component/EventsTrackers/BrushTracker.js +2 -2
- package/lib/component/EventsTrackers/KeysListenerTracker.js +12 -3
- package/lib/component/NMRium.d.ts +1 -1
- package/lib/component/NMRium.js +28 -25
- package/lib/component/hooks/useActiveSpectrumStyleOptions.d.ts +6 -0
- package/lib/component/hooks/useActiveSpectrumStyleOptions.js +15 -0
- package/lib/component/hooks/useXYReduce.d.ts +2 -1
- package/lib/component/loader/DropZone.js +1 -1
- package/lib/component/modal/ModalStyle.js +5 -2
- package/lib/component/modal/MoleculeStructureEditorModal.js +3 -2
- package/lib/component/modal/MultipleSpectraFiltersModal/index.js +10 -1
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.d.ts +2 -0
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +35 -0
- package/lib/component/panels/MoleculesPanel/MoleculePanel.js +49 -67
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +3 -8
- package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +2 -23
- package/lib/component/panels/Panels.js +10 -0
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DHistogram.js +1 -1
- package/lib/component/panels/ZonesPanel/ZonesTable.js +9 -2
- package/lib/component/reducer/Reducer.d.ts +0 -16
- package/lib/component/reducer/Reducer.js +4 -5
- package/lib/component/reducer/actions/FiltersActions.d.ts +3 -1
- package/lib/component/reducer/actions/FiltersActions.js +60 -18
- package/lib/component/reducer/actions/LoadActions.js +2 -3
- package/lib/component/reducer/actions/MoleculeActions.js +2 -2
- package/lib/component/reducer/actions/PreferencesActions.js +4 -7
- package/lib/component/reducer/actions/RangesActions.js +1 -1
- package/lib/component/reducer/actions/ToolsActions.d.ts +1 -3
- package/lib/component/reducer/actions/ToolsActions.js +1 -30
- package/lib/component/reducer/helper/getRange.d.ts +6 -1
- package/lib/component/reducer/helper/getRange.js +1 -1
- package/lib/component/toolbar/FunctionToolBar.js +2 -5
- package/lib/component/utility/PathBuilder.d.ts +7 -0
- package/lib/component/utility/PathBuilder.js +17 -0
- package/lib/component/utility/getSpectraByNucleus.d.ts +3 -0
- package/lib/component/utility/getSpectraByNucleus.js +4 -0
- package/lib/data/Filters.d.ts +2 -1
- package/lib/data/Filters.js +2 -1
- package/lib/data/data1d/Spectrum1D/ranges/addRange.js +5 -2
- package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +0 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectSignal.d.ts +3 -2
- package/lib/data/data1d/Spectrum1D/ranges/detectSignal.js +23 -15
- package/lib/data/data1d/filter1d/exclusionZones.d.ts +16 -0
- package/lib/data/data1d/filter1d/exclusionZones.js +28 -0
- package/lib/data/types/data1d/ExclusionZone.d.ts +5 -0
- package/lib/data/types/data1d/ExclusionZone.js +1 -0
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/Chart1D.js +3 -3
- package/lib-cjs/component/1d/ExclusionZoneAnnotation.js +23 -0
- package/lib-cjs/component/1d/ExclusionZonesAnnotations.js +52 -0
- package/lib-cjs/component/1d/Line.js +11 -23
- package/lib-cjs/component/1d/Viewer1D.js +36 -5
- package/lib-cjs/component/1d/ranges/Ranges.js +1 -1
- package/lib-cjs/component/1d/{BaseLineZones.js → tool/BaseLineZones.js} +5 -5
- package/lib-cjs/component/1d/utilities/useIntegralPath.js +9 -10
- package/lib-cjs/component/2d/Contours.js +12 -11
- package/lib-cjs/component/2d/Left1DChart.js +7 -9
- package/lib-cjs/component/2d/Top1DChart.js +7 -7
- package/lib-cjs/component/2d/tools/slicing/HorizontalSliceChart.js +7 -7
- package/lib-cjs/component/2d/tools/slicing/VerticalSliceChart.js +7 -9
- package/lib-cjs/component/EventsTrackers/BrushTracker.js +2 -2
- package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +12 -3
- package/lib-cjs/component/NMRium.js +28 -25
- package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +21 -0
- package/lib-cjs/component/loader/DropZone.js +1 -1
- package/lib-cjs/component/modal/ModalStyle.js +5 -2
- package/lib-cjs/component/modal/MoleculeStructureEditorModal.js +3 -2
- package/lib-cjs/component/modal/MultipleSpectraFiltersModal/index.js +10 -1
- package/lib-cjs/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +40 -0
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanel.js +48 -66
- package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +3 -8
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -22
- package/lib-cjs/component/panels/Panels.js +10 -0
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum2DHistogram.js +1 -1
- package/lib-cjs/component/panels/ZonesPanel/ZonesTable.js +8 -1
- package/lib-cjs/component/reducer/Reducer.js +4 -5
- package/lib-cjs/component/reducer/actions/FiltersActions.js +62 -18
- package/lib-cjs/component/reducer/actions/LoadActions.js +2 -3
- package/lib-cjs/component/reducer/actions/MoleculeActions.js +2 -2
- package/lib-cjs/component/reducer/actions/PreferencesActions.js +4 -7
- package/lib-cjs/component/reducer/actions/RangesActions.js +1 -1
- package/lib-cjs/component/reducer/actions/ToolsActions.js +1 -32
- package/lib-cjs/component/reducer/helper/getRange.js +1 -1
- package/lib-cjs/component/toolbar/FunctionToolBar.js +2 -5
- package/lib-cjs/component/utility/PathBuilder.js +21 -0
- package/lib-cjs/component/utility/getSpectraByNucleus.js +11 -0
- package/lib-cjs/data/Filters.js +3 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/addRange.js +5 -2
- package/lib-cjs/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/detectRange.js +0 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/detectSignal.js +24 -15
- package/lib-cjs/data/data1d/filter1d/exclusionZones.js +34 -0
- package/lib-cjs/data/types/data1d/ExclusionZone.js +2 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +21 -21
- package/lib/component/1d/ExclusionZone.d.ts +0 -8
- package/lib/component/1d/ExclusionZone.js +0 -30
- package/lib/component/1d/ExclusionZones.d.ts +0 -2
- package/lib/component/1d/ExclusionZones.js +0 -10
- package/lib-cjs/component/1d/ExclusionZone.js +0 -32
- package/lib-cjs/component/1d/ExclusionZones.js +0 -16
|
@@ -5,8 +5,11 @@ import { updateXShift } from '../../../data/data1d/Spectrum1D';
|
|
|
5
5
|
import { apply as autoPhaseCorrection } from '../../../data/data1d/filter1d/autoPhaseCorrection';
|
|
6
6
|
import { apply as phaseCorrection } from '../../../data/data1d/filter1d/phaseCorrection';
|
|
7
7
|
import { updateShift as update2dShift } from '../../../data/data2d/Spectrum2D';
|
|
8
|
+
import generateID from '../../../data/utilities/generateID';
|
|
9
|
+
import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
|
|
8
10
|
import nucleusToString from '../../utility/nucleusToString';
|
|
9
11
|
import zoomHistoryManager from '../helper/ZoomHistoryManager';
|
|
12
|
+
import getRange from '../helper/getRange';
|
|
10
13
|
import { setDomain, setMode } from './DomainActions';
|
|
11
14
|
import { changeSpectrumVerticalAlignment } from './PreferencesActions';
|
|
12
15
|
import { resetSelectedTool } from './ToolsActions';
|
|
@@ -243,25 +246,64 @@ function filterSnapshotHandler(draft, action) {
|
|
|
243
246
|
resetSpectrumByFilter(draft, action.id);
|
|
244
247
|
}
|
|
245
248
|
function handleMultipleSpectraFilter(draft, action) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
FiltersManager.applyFilter(datum, filters);
|
|
262
|
-
}
|
|
249
|
+
const spectra = getSpectraByNucleus(draft.activeTab, draft.data);
|
|
250
|
+
if (spectra && spectra.length > 0 && Array.isArray(action.payload)) {
|
|
251
|
+
const exclusions = spectra[0].filters.find((f) => f.name === Filters.exclusionZones.id)
|
|
252
|
+
?.value || [];
|
|
253
|
+
for (const spectrum of spectra) {
|
|
254
|
+
const filters = action.payload.map((filter) => {
|
|
255
|
+
if (filter.name === Filters.equallySpaced.id) {
|
|
256
|
+
return {
|
|
257
|
+
...filter,
|
|
258
|
+
options: { ...filter.options, exclusions },
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
return filter;
|
|
262
|
+
});
|
|
263
|
+
FiltersManager.applyFilter(spectrum, filters);
|
|
263
264
|
}
|
|
264
265
|
}
|
|
265
266
|
setDomain(draft);
|
|
266
267
|
}
|
|
267
|
-
|
|
268
|
+
function handleAddExclusionZone(draft, action) {
|
|
269
|
+
const { from: startX, to: endX } = action.payload;
|
|
270
|
+
const range = getRange(draft, { startX, endX });
|
|
271
|
+
let spectra;
|
|
272
|
+
if (draft.activeSpectrum?.id) {
|
|
273
|
+
const index = draft.activeSpectrum?.index;
|
|
274
|
+
spectra = [draft.data[index]];
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
spectra = getSpectraByNucleus(draft.activeTab, draft.data);
|
|
278
|
+
}
|
|
279
|
+
for (const spectrum of spectra) {
|
|
280
|
+
FiltersManager.applyFilter(spectrum, [
|
|
281
|
+
{
|
|
282
|
+
name: Filters.exclusionZones.id,
|
|
283
|
+
options: [
|
|
284
|
+
{
|
|
285
|
+
id: generateID(),
|
|
286
|
+
from: range[0],
|
|
287
|
+
to: range[1],
|
|
288
|
+
},
|
|
289
|
+
],
|
|
290
|
+
},
|
|
291
|
+
]);
|
|
292
|
+
}
|
|
293
|
+
setDomain(draft);
|
|
294
|
+
}
|
|
295
|
+
function handleDeleteExclusionZone(draft, action) {
|
|
296
|
+
const { id, spectrumID } = action.payload;
|
|
297
|
+
const spectrumIndex = draft.data.findIndex((spectrum) => spectrum.id === spectrumID);
|
|
298
|
+
const exclusionZonesFilter = draft.data[spectrumIndex].filters.find((filter) => filter.name === Filters.exclusionZones.id);
|
|
299
|
+
if (exclusionZonesFilter) {
|
|
300
|
+
if (exclusionZonesFilter.value.length === 1) {
|
|
301
|
+
FiltersManager.deleteFilter(draft.data[spectrumIndex], exclusionZonesFilter.id);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
exclusionZonesFilter.value = exclusionZonesFilter.value.filter((zone) => zone.id !== id);
|
|
305
|
+
FiltersManager.reapplyFilters(draft.data[spectrumIndex]);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
export { shiftSpectrumAlongXAxis, applyZeroFillingFilter, applyFFTFilter, applyManualPhaseCorrectionFilter, applyAutoPhaseCorrectionFilter, applyAbsoluteFilter, calculateManualPhaseCorrection, handleMultipleSpectraFilter, enableFilter, deleteFilter, deleteSpectraFilter, handleBaseLineCorrectionFilter, filterSnapshotHandler, resetSpectrumByFilter, handleAddExclusionZone, handleDeleteExclusionZone, };
|
|
@@ -12,17 +12,16 @@ function setColors(draft, colors) {
|
|
|
12
12
|
draft.usedColors['2d'] = draft.usedColors['2d'].concat(colors['2d']);
|
|
13
13
|
}
|
|
14
14
|
function setData(draft, data) {
|
|
15
|
-
const { spectra, molecules, correlations,
|
|
15
|
+
const { spectra, molecules, correlations, usedColors } = data || {
|
|
16
16
|
spectra: [],
|
|
17
17
|
molecules: [],
|
|
18
18
|
correlations: {},
|
|
19
19
|
multipleAnalysis: {},
|
|
20
|
-
exclusionZones:
|
|
20
|
+
exclusionZones: [],
|
|
21
21
|
};
|
|
22
22
|
setColors(draft, usedColors);
|
|
23
23
|
draft.data = spectra;
|
|
24
24
|
draft.molecules = MoleculeManager.fromJSON(molecules);
|
|
25
|
-
draft.toolOptions.data.exclusionZones = exclusionZones;
|
|
26
25
|
if (!correlations || Object.keys(correlations).length === 0) {
|
|
27
26
|
draft.correlations = buildCorrelationData([], {
|
|
28
27
|
tolerance: DefaultTolerance,
|
|
@@ -13,8 +13,8 @@ function addMoleculeHandler(draft, molfile) {
|
|
|
13
13
|
* if it's the first creation of a molecule after the molecules list was empty,
|
|
14
14
|
* set the relative sum for ranges and integrals base on the first molecule
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const molecule = draft.molecules[0] || null;
|
|
17
|
+
if (isEmpty && molecule) {
|
|
18
18
|
changeSpectraRelativeSum(draft, molecule.key, molecule);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { original } from 'immer';
|
|
2
1
|
import cloneDeep from 'lodash/cloneDeep';
|
|
3
2
|
import GroupByInfoKey from '../../utility/GroupByInfoKey';
|
|
4
3
|
import nucleusToString from '../../utility/nucleusToString';
|
|
@@ -43,8 +42,7 @@ function changeSpectrumVerticalAlignment(draft, options) {
|
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
function setKeyPreferencesHandler(draft, keyCode) {
|
|
46
|
-
const
|
|
47
|
-
const { activeTab, data, activeSpectrum, zoom, xDomain, xDomains, yDomain, yDomains, originDomain, margin, displayerMode, tabActiveSpectrum, } = state;
|
|
45
|
+
const { activeTab, data, activeSpectrum, zoom, xDomain, xDomains, yDomain, yDomains, originDomain, margin, displayerMode, tabActiveSpectrum, } = draft;
|
|
48
46
|
if (activeTab) {
|
|
49
47
|
const groupByNucleus = GroupByInfoKey('nucleus');
|
|
50
48
|
const spectrumsGroupsList = groupByNucleus(data);
|
|
@@ -81,11 +79,10 @@ function setKeyPreferencesHandler(draft, keyCode) {
|
|
|
81
79
|
}
|
|
82
80
|
}
|
|
83
81
|
function applyKeyPreferencesHandler(draft, keyCode) {
|
|
84
|
-
const
|
|
85
|
-
const preferences = state.keysPreferences[keyCode];
|
|
82
|
+
const preferences = draft.keysPreferences[keyCode];
|
|
86
83
|
if (preferences) {
|
|
87
84
|
draft.activeTab = preferences.activeTab;
|
|
88
|
-
|
|
85
|
+
draft.data.forEach((datum, index) => {
|
|
89
86
|
if (nucleusToString(datum.info.nucleus) === preferences.activeTab) {
|
|
90
87
|
draft.data[index].display = Object.assign(cloneDeep(datum.display), preferences.data[datum.id].display);
|
|
91
88
|
}
|
|
@@ -103,7 +100,7 @@ function applyKeyPreferencesHandler(draft, keyCode) {
|
|
|
103
100
|
if (draft.displayerMode === DISPLAYER_MODE.DM_2D) {
|
|
104
101
|
for (const datumID of Object.keys(preferences.level)) {
|
|
105
102
|
const { levelPositive, levelNegative } = preferences.level[datumID];
|
|
106
|
-
const index =
|
|
103
|
+
const index = draft.data.findIndex((datum) => datum.id === datumID);
|
|
107
104
|
const processController = draft.data[index]
|
|
108
105
|
.processingController;
|
|
109
106
|
processController.setLevel(levelPositive, levelNegative);
|
|
@@ -202,7 +202,7 @@ function handleChangeRangeSum(draft, options) {
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
function handleAddRange(draft, action) {
|
|
205
|
-
const { startX, endX } = action;
|
|
205
|
+
const { startX, endX } = action.payload;
|
|
206
206
|
const { activeSpectrum, activeTab: nucleus, molecules } = draft;
|
|
207
207
|
const range = getRange(draft, { startX, endX });
|
|
208
208
|
if (activeSpectrum?.id) {
|
|
@@ -30,6 +30,4 @@ declare function levelChangeHandler(draft: Draft<State>, { deltaY, shiftKey }: {
|
|
|
30
30
|
}): void;
|
|
31
31
|
declare function setSpectraSameTopHandler(draft: Draft<State>): void;
|
|
32
32
|
declare function resetSpectraScale(draft: Draft<State>): void;
|
|
33
|
-
|
|
34
|
-
declare function handleDeleteExclusionZone(draft: Draft<State>, action: any): void;
|
|
35
|
-
export { resetSelectedTool, setSelectedTool, setSelectedOptionPanel, setSpectrumsVerticalAlign, handleChangeSpectrumDisplayMode, handleAddBaseLineZone, handleDeleteBaseLineZone, handleToggleRealImaginaryVisibility, handleBrushEnd, setVerticalIndicatorXPosition, handleZoom, zoomOut, handelSetActiveTab, levelChangeHandler, setActiveTab, setTab, setSpectraSameTopHandler, resetSpectraScale, handleAddExclusionZone, handleDeleteExclusionZone, };
|
|
33
|
+
export { resetSelectedTool, setSelectedTool, setSelectedOptionPanel, setSpectrumsVerticalAlign, handleChangeSpectrumDisplayMode, handleAddBaseLineZone, handleDeleteBaseLineZone, handleToggleRealImaginaryVisibility, handleBrushEnd, setVerticalIndicatorXPosition, handleZoom, zoomOut, handelSetActiveTab, levelChangeHandler, setActiveTab, setTab, setSpectraSameTopHandler, resetSpectraScale, };
|
|
@@ -450,33 +450,4 @@ function resetSpectraScale(draft) {
|
|
|
450
450
|
draft.yDomain = draft.originDomain.yDomain;
|
|
451
451
|
setZoom(draft, { scale: 0.8 });
|
|
452
452
|
}
|
|
453
|
-
|
|
454
|
-
const { from, to } = action.payload;
|
|
455
|
-
const scaleX = getXScale(draft);
|
|
456
|
-
const start = scaleX.invert(from);
|
|
457
|
-
const end = scaleX.invert(to);
|
|
458
|
-
let zone = [];
|
|
459
|
-
if (start > end) {
|
|
460
|
-
zone = [end, start];
|
|
461
|
-
}
|
|
462
|
-
else {
|
|
463
|
-
zone = [start, end];
|
|
464
|
-
}
|
|
465
|
-
const newExclusionZone = {
|
|
466
|
-
id: generateID(),
|
|
467
|
-
from: zone[0],
|
|
468
|
-
to: zone[1],
|
|
469
|
-
};
|
|
470
|
-
if (draft.toolOptions.data.exclusionZones[draft.activeTab]) {
|
|
471
|
-
draft.toolOptions.data.exclusionZones[draft.activeTab].push(newExclusionZone);
|
|
472
|
-
}
|
|
473
|
-
else {
|
|
474
|
-
draft.toolOptions.data.exclusionZones[draft.activeTab] = [newExclusionZone];
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
function handleDeleteExclusionZone(draft, action) {
|
|
478
|
-
const id = action.payload.id;
|
|
479
|
-
const index = draft.toolOptions.data.exclusionZones[draft.activeTab].findIndex((zone) => zone.id === id);
|
|
480
|
-
draft.toolOptions.data.exclusionZones[draft.activeTab].splice(index, 1);
|
|
481
|
-
}
|
|
482
|
-
export { resetSelectedTool, setSelectedTool, setSelectedOptionPanel, setSpectrumsVerticalAlign, handleChangeSpectrumDisplayMode, handleAddBaseLineZone, handleDeleteBaseLineZone, handleToggleRealImaginaryVisibility, handleBrushEnd, setVerticalIndicatorXPosition, handleZoom, zoomOut, handelSetActiveTab, levelChangeHandler, setActiveTab, setTab, setSpectraSameTopHandler, resetSpectraScale, handleAddExclusionZone, handleDeleteExclusionZone, };
|
|
453
|
+
export { resetSelectedTool, setSelectedTool, setSelectedOptionPanel, setSpectrumsVerticalAlign, handleChangeSpectrumDisplayMode, handleAddBaseLineZone, handleDeleteBaseLineZone, handleToggleRealImaginaryVisibility, handleBrushEnd, setVerticalIndicatorXPosition, handleZoom, zoomOut, handelSetActiveTab, levelChangeHandler, setActiveTab, setTab, setSpectraSameTopHandler, resetSpectraScale, };
|
|
@@ -37,9 +37,6 @@ function FunctionToolBarInner({ defaultValue, activeSpectrum, info, datum, displ
|
|
|
37
37
|
const isButtonVisible = useCallback((toolKey) => {
|
|
38
38
|
return !lodashGet(preferences, `display.toolBarButtons.${toolKey}`);
|
|
39
39
|
}, [preferences]);
|
|
40
|
-
const isPanelVisible = useCallback((panelKey) => {
|
|
41
|
-
return !lodashGet(preferences, `display.panels.${panelKey}`);
|
|
42
|
-
}, [preferences]);
|
|
43
40
|
return (_jsxs(_Fragment, { children: [_jsxs(ToggleButtonGroup, { value: option, onChange: handleChange, children: [isButtonVisible('hideZoomTool') && (_jsx(ToggleButton, { value: options.zoom.id, id: "zoomIn", title: `${options.zoom.label} ( Press z )`, children: _jsx("div", { style: { fontSize: 14 }, children: _jsx(FaSearchPlus, {}, void 0) }, void 0) }, options.zoom.id)), isButtonVisible('hideZoomOutTool') && (_jsx(Toolbar.Item, { id: "zoom-out", onClick: handleFullZoomOut, title: "Horizontal zoom out ( Press f ), Horizontal and Vertical zoom out, double click ( Press ff )", children: _jsx("div", { style: { fontSize: 14 }, children: _jsx(FaExpand, {}, void 0) }, void 0) }, void 0)), displayerMode === DISPLAYER_MODE.DM_1D &&
|
|
44
41
|
isButtonVisible('hidePeakTool') && (_jsx(ToggleButton, { value: options.peakPicking.id, title: `${options.peakPicking.label} ( Press p )`, isVisible: activeSpectrum && !info?.isFid ? true : false, id: "peakPicking", children: _jsx(SvgNmrPeakPicking, {}, void 0) }, options.peakPicking.id)), displayerMode === DISPLAYER_MODE.DM_1D &&
|
|
45
42
|
isButtonVisible('hideIntegralTool') && (_jsx(ToggleButton, { value: options.integral.id, isVisible: activeSpectrum && !info?.isFid ? true : false, id: "integralPicking", title: `${options.integral.label} ( Press i )`, children: _jsx(SvgNmrIntegrate, {}, void 0) }, options.integral.id)), displayerMode === DISPLAYER_MODE.DM_2D &&
|
|
@@ -61,8 +58,8 @@ function FunctionToolBarInner({ defaultValue, activeSpectrum, info, datum, displ
|
|
|
61
58
|
? true
|
|
62
59
|
: false, children: _jsx(SvgNmrBaselineCorrection, {}, void 0) }, options.baseLineCorrection.id)), displayerMode === DISPLAYER_MODE.DM_1D &&
|
|
63
60
|
isButtonVisible('hideExclusionZonesTool') &&
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
!info?.isFid &&
|
|
62
|
+
ftCounter > 0 && (_jsx(ToggleButton, { value: options.exclusionZones.id, title: `${options.exclusionZones.label} ( Press e )`, id: "exclusionZones", children: _jsx("div", { style: { fontSize: 18 }, children: _jsx(SvgNmrMultipleAnalysis, {}, void 0) }, void 0) }, options.exclusionZones.id))] }, void 0), displayerMode === DISPLAYER_MODE.DM_1D &&
|
|
66
63
|
isButtonVisible('hideFFTTool') &&
|
|
67
64
|
info &&
|
|
68
65
|
Filters.fft.isApplicable({ info }) && (_jsx(Toolbar.Item, { id: "fft-filter", className: "cheminfo", title: "FFT Filter", onClick: handleOnFFTFilter, children: _jsx(SvgNmrFourierTransform, {}, void 0) }, void 0))] }, void 0));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class PathBuilder {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.array = [];
|
|
4
|
+
}
|
|
5
|
+
moveTo(x, y) {
|
|
6
|
+
this.array.push(`M ${x} ${y}`);
|
|
7
|
+
}
|
|
8
|
+
lineTo(x, y) {
|
|
9
|
+
this.array.push(`L ${x} ${y}`);
|
|
10
|
+
}
|
|
11
|
+
closePath() {
|
|
12
|
+
this.array.push('Z');
|
|
13
|
+
}
|
|
14
|
+
toString() {
|
|
15
|
+
return this.array.join(' ');
|
|
16
|
+
}
|
|
17
|
+
}
|
package/lib/data/Filters.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import * as baselineCorrection from './data1d/filter1d/baselineCorrection';
|
|
|
4
4
|
import * as centerMean from './data1d/filter1d/centerMean';
|
|
5
5
|
import * as digitalFilter from './data1d/filter1d/digitalFilter';
|
|
6
6
|
import * as equallySpaced from './data1d/filter1d/equallySpaced';
|
|
7
|
+
import * as exclusionZones from './data1d/filter1d/exclusionZones';
|
|
7
8
|
import * as fft from './data1d/filter1d/fft';
|
|
8
9
|
import * as fromTo from './data1d/filter1d/fromTo';
|
|
9
10
|
import * as lineBroadening from './data1d/filter1d/lineBroadening';
|
|
@@ -14,4 +15,4 @@ import * as standardDeviation from './data1d/filter1d/standardDeviation';
|
|
|
14
15
|
import * as zeroFilling from './data1d/filter1d/zeroFilling';
|
|
15
16
|
import * as shift2DX from './data2d/filter2d/shiftX';
|
|
16
17
|
import * as shift2DY from './data2d/filter2d/shiftY';
|
|
17
|
-
export { absolute, baselineCorrection, lineBroadening, fft, phaseCorrection, autoPhaseCorrection, shiftX, zeroFilling, digitalFilter, fromTo, equallySpaced, standardDeviation, centerMean, pareto, shift2DX, shift2DY, };
|
|
18
|
+
export { absolute, baselineCorrection, lineBroadening, fft, phaseCorrection, autoPhaseCorrection, shiftX, zeroFilling, digitalFilter, fromTo, equallySpaced, standardDeviation, centerMean, pareto, exclusionZones, shift2DX, shift2DY, };
|
package/lib/data/Filters.js
CHANGED
|
@@ -4,6 +4,7 @@ import * as baselineCorrection from './data1d/filter1d/baselineCorrection';
|
|
|
4
4
|
import * as centerMean from './data1d/filter1d/centerMean';
|
|
5
5
|
import * as digitalFilter from './data1d/filter1d/digitalFilter';
|
|
6
6
|
import * as equallySpaced from './data1d/filter1d/equallySpaced';
|
|
7
|
+
import * as exclusionZones from './data1d/filter1d/exclusionZones';
|
|
7
8
|
import * as fft from './data1d/filter1d/fft';
|
|
8
9
|
import * as fromTo from './data1d/filter1d/fromTo';
|
|
9
10
|
import * as lineBroadening from './data1d/filter1d/lineBroadening';
|
|
@@ -14,4 +15,4 @@ import * as standardDeviation from './data1d/filter1d/standardDeviation';
|
|
|
14
15
|
import * as zeroFilling from './data1d/filter1d/zeroFilling';
|
|
15
16
|
import * as shift2DX from './data2d/filter2d/shiftX';
|
|
16
17
|
import * as shift2DY from './data2d/filter2d/shiftY';
|
|
17
|
-
export { absolute, baselineCorrection, lineBroadening, fft, phaseCorrection, autoPhaseCorrection, shiftX, zeroFilling, digitalFilter, fromTo, equallySpaced, standardDeviation, centerMean, pareto, shift2DX, shift2DY, };
|
|
18
|
+
export { absolute, baselineCorrection, lineBroadening, fft, phaseCorrection, autoPhaseCorrection, shiftX, zeroFilling, digitalFilter, fromTo, equallySpaced, standardDeviation, centerMean, pareto, exclusionZones, shift2DX, shift2DY, };
|
|
@@ -9,14 +9,17 @@ export function addRange(datum, options) {
|
|
|
9
9
|
const { from, to, molecules, nucleus } = options;
|
|
10
10
|
const { x, re } = datum.data;
|
|
11
11
|
const absolute = xyIntegration({ x, y: re }, { from, to, reverse: true });
|
|
12
|
-
|
|
12
|
+
// detectSignal use the advance multiplet-analysis that can crash if too many points
|
|
13
|
+
const signal = detectSignal(x, re, from, to, datum.info.originFrequency);
|
|
14
|
+
if (!signal)
|
|
15
|
+
return;
|
|
13
16
|
try {
|
|
14
17
|
const range = {
|
|
15
18
|
id: generateID(),
|
|
16
19
|
from,
|
|
17
20
|
to,
|
|
18
21
|
absolute,
|
|
19
|
-
signals: [{ id: generateID(), ...
|
|
22
|
+
signals: [{ id: generateID(), ...signal }],
|
|
20
23
|
kind: DatumKind.signal,
|
|
21
24
|
integration: 0,
|
|
22
25
|
};
|
|
@@ -30,12 +30,17 @@ export default function autoRangesDetection(datum1D, options = {}) {
|
|
|
30
30
|
re = re.slice(windowFromIndex, windowToIndex);
|
|
31
31
|
}
|
|
32
32
|
if (originFrequency) {
|
|
33
|
-
|
|
33
|
+
// we calculate the number of points per Hz
|
|
34
|
+
let pointsPerHz = 1 / originFrequency / (x[1] - x[0]);
|
|
35
|
+
// we can consider a peak with of 0.5 Hz for the windowSize
|
|
36
|
+
let ws = Math.max(Math.round(pointsPerHz / 2), 5);
|
|
34
37
|
peakPickingOptions.sgOptions = {
|
|
35
38
|
windowSize: ws - (ws % 2) + 1,
|
|
36
39
|
polynomial: 3,
|
|
37
40
|
};
|
|
38
41
|
}
|
|
42
|
+
peakPickingOptions.smoothY = undefined;
|
|
43
|
+
peakPickingOptions.sgOptions = undefined;
|
|
39
44
|
const ranges = xyAutoRangesPicking({ x, y: re }, {
|
|
40
45
|
peakPicking: peakPickingOptions,
|
|
41
46
|
ranges: rangesOptions,
|
|
@@ -5,7 +5,6 @@ export function detectRange(datum, options) {
|
|
|
5
5
|
const { from, to } = options;
|
|
6
6
|
const { x, re: y } = datum.data;
|
|
7
7
|
const absolute = xyIntegration({ x, y }, { from, to, reverse: true });
|
|
8
|
-
// @ts-expect-error Types will be fixed in ml-spectra-processing.
|
|
9
8
|
const min = xyMinYPoint({ x, y }, { from, to }).y;
|
|
10
9
|
const max = xyMaxYPoint({ x, y }, { from, to }).y;
|
|
11
10
|
const shiftX = getShiftX(datum);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const MAX_LENGTH = 2048;
|
|
2
|
+
export default function detectSignal(x: Float64Array, re: Float64Array, from: any, to: any, frequency: any): {
|
|
2
3
|
multiplicity: any;
|
|
3
4
|
kind: string;
|
|
4
5
|
delta: any;
|
|
5
6
|
js: any;
|
|
6
|
-
};
|
|
7
|
+
} | undefined;
|
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
import { xGetFromToIndex } from 'ml-spectra-processing';
|
|
2
2
|
import { analyseMultiplet } from 'multiplet-analysis';
|
|
3
|
+
export const MAX_LENGTH = 2048;
|
|
3
4
|
export default function detectSignal(x, re, from, to, frequency) {
|
|
4
5
|
const { fromIndex, toIndex } = xGetFromToIndex(x, {
|
|
5
6
|
from: from,
|
|
6
7
|
to: to,
|
|
7
8
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
if (toIndex - fromIndex <= MAX_LENGTH) {
|
|
10
|
+
const data = {
|
|
11
|
+
x: x.subarray(fromIndex, toIndex),
|
|
12
|
+
y: re.subarray(fromIndex, toIndex),
|
|
13
|
+
};
|
|
14
|
+
const result = analyseMultiplet(data, {
|
|
15
|
+
frequency: frequency,
|
|
16
|
+
takeBestPartMultiplet: true,
|
|
17
|
+
symmetrizeEachStep: true,
|
|
18
|
+
});
|
|
19
|
+
if (result && result.chemShift === undefined)
|
|
20
|
+
return;
|
|
21
|
+
return {
|
|
22
|
+
multiplicity: result.js.map((j) => j.multiplicity).join(''),
|
|
23
|
+
kind: 'signal',
|
|
24
|
+
delta: result.chemShift,
|
|
25
|
+
js: result.js,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
throw new Error(`length of signal should not exceed ${MAX_LENGTH} points`);
|
|
30
|
+
}
|
|
23
31
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Datum1D } from '../../types/data1d/Datum1D';
|
|
2
|
+
export declare const id = "exclusionZones";
|
|
3
|
+
export declare const name = "Exclusion Zones";
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {Datum1d} datum1d
|
|
7
|
+
*/
|
|
8
|
+
export declare function apply(datum1D: Datum1D, zones?: never[]): void;
|
|
9
|
+
export declare function isApplicable(datum1D: Datum1D): boolean;
|
|
10
|
+
export declare function reduce(previousValue: any, newValue: any): {
|
|
11
|
+
once: boolean;
|
|
12
|
+
reduce: {
|
|
13
|
+
from: number;
|
|
14
|
+
to: number;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { xySetYValue, zonesNormalize } from 'ml-spectra-processing';
|
|
2
|
+
export const id = 'exclusionZones';
|
|
3
|
+
export const name = 'Exclusion Zones';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {Datum1d} datum1d
|
|
7
|
+
*/
|
|
8
|
+
export function apply(datum1D, zones = []) {
|
|
9
|
+
if (!isApplicable(datum1D)) {
|
|
10
|
+
throw new Error('Exclusion Zones filter not applicable on this data');
|
|
11
|
+
}
|
|
12
|
+
const { x, re, im } = datum1D.data;
|
|
13
|
+
datum1D.data.re = xySetYValue({ x, y: re }, { zones }).y;
|
|
14
|
+
datum1D.data.im = (im
|
|
15
|
+
? xySetYValue({ x, y: re }, { zones })
|
|
16
|
+
: im);
|
|
17
|
+
}
|
|
18
|
+
export function isApplicable(datum1D) {
|
|
19
|
+
if (datum1D.info.isComplex && datum1D.info.isFt)
|
|
20
|
+
return true;
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
export function reduce(previousValue, newValue) {
|
|
24
|
+
return {
|
|
25
|
+
once: true,
|
|
26
|
+
reduce: zonesNormalize(previousValue.concat(newValue)),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/versionInfo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default { version: 'v0.
|
|
1
|
+
export default { version: 'v0.20.1' };
|
|
@@ -4,8 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const
|
|
8
|
-
const ExclusionZones_1 = __importDefault(require("./ExclusionZones"));
|
|
7
|
+
const ExclusionZonesAnnotations_1 = __importDefault(require("./ExclusionZonesAnnotations"));
|
|
9
8
|
const IntegralsSeries_1 = __importDefault(require("./IntegralsSeries"));
|
|
10
9
|
const LinesSeries_1 = __importDefault(require("./LinesSeries"));
|
|
11
10
|
const PeakAnnotations_1 = __importDefault(require("./PeakAnnotations"));
|
|
@@ -14,7 +13,8 @@ const XAxis_1 = __importDefault(require("./XAxis"));
|
|
|
14
13
|
const JGraph_1 = __importDefault(require("./jCouplingGraph/JGraph"));
|
|
15
14
|
const MultiAnalysisRanges_1 = __importDefault(require("./multiAnalysis/MultiAnalysisRanges"));
|
|
16
15
|
const Ranges_1 = __importDefault(require("./ranges/Ranges"));
|
|
16
|
+
const BaseLineZones_1 = __importDefault(require("./tool/BaseLineZones"));
|
|
17
17
|
function Chart1D({ mode, width, height, margin, displayerKey }) {
|
|
18
|
-
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, id: "nmrSVG", children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: `${displayerKey}clip-chart-1d`, children: (0, jsx_runtime_1.jsx)("rect", { width: `${width - margin.left - margin.right}`, height: `${height}`, x: `${margin.left}`, y: `${0}` }, void 0) }, void 0) }, void 0), (0, jsx_runtime_1.jsx)(LinesSeries_1.default, {}, void 0), (0, jsx_runtime_1.jsx)(IntegralsSeries_1.default, {}, void 0), (0, jsx_runtime_1.jsx)(PeakAnnotations_1.default, {}, void 0), (0, jsx_runtime_1.jsx)(Ranges_1.default, {}, void 0), (0, jsx_runtime_1.jsx)(JGraph_1.default, {}, void 0), (0, jsx_runtime_1.jsx)(MultiAnalysisRanges_1.default, {}, void 0), (0, jsx_runtime_1.jsx)(BaseLineZones_1.default, {}, void 0), (0, jsx_runtime_1.jsx)(
|
|
18
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, id: "nmrSVG", children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: `${displayerKey}clip-chart-1d`, children: (0, jsx_runtime_1.jsx)("rect", { width: `${width - margin.left - margin.right}`, height: `${height}`, x: `${margin.left}`, y: `${0}` }, void 0) }, void 0) }, void 0), (0, jsx_runtime_1.jsx)(LinesSeries_1.default, {}, void 0), (0, jsx_runtime_1.jsx)(IntegralsSeries_1.default, {}, void 0), (0, jsx_runtime_1.jsx)(PeakAnnotations_1.default, {}, void 0), (0, jsx_runtime_1.jsx)(Ranges_1.default, {}, void 0), (0, jsx_runtime_1.jsx)(JGraph_1.default, {}, void 0), (0, jsx_runtime_1.jsx)(MultiAnalysisRanges_1.default, {}, void 0), (0, jsx_runtime_1.jsx)(BaseLineZones_1.default, {}, void 0), (0, jsx_runtime_1.jsx)(ExclusionZonesAnnotations_1.default, {}, void 0), (0, jsx_runtime_1.jsx)(ResurrectedDatabaseRanges_1.default, {}, void 0), (0, jsx_runtime_1.jsx)("g", { className: "container", style: { pointerEvents: 'none' }, children: (0, jsx_runtime_1.jsx)(XAxis_1.default, { showGrid: true, mode: mode }, void 0) }, void 0)] }, void 0));
|
|
19
19
|
}
|
|
20
20
|
exports.default = Chart1D;
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const ScaleContext_1 = require("../context/ScaleContext");
|
|
9
|
+
const highlight_1 = require("../highlight");
|
|
10
|
+
const useActiveSpectrumStyleOptions_1 = __importDefault(require("../hooks/useActiveSpectrumStyleOptions"));
|
|
11
|
+
function ExclusionZoneAnnotation({ zone, color, vAlign, spectrumID, }) {
|
|
12
|
+
const { scaleX, scaleY } = (0, ScaleContext_1.useScaleChecked)();
|
|
13
|
+
const highlight = (0, highlight_1.useHighlight)([zone.id], {
|
|
14
|
+
type: highlight_1.HighlightedSource.EXCLUSION_ZONE,
|
|
15
|
+
extra: { id: zone.id, spectrumID },
|
|
16
|
+
});
|
|
17
|
+
const { opacity } = (0, useActiveSpectrumStyleOptions_1.default)(spectrumID);
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)("g", { transform: `translate(${scaleX()(zone.to)},0)`, children: (0, jsx_runtime_1.jsx)("rect", { x: "0", transform: `translate(0,${scaleY()(0) - (vAlign + 5)})`, width: `${scaleX()(zone.from) - scaleX()(zone.to)}`, height: "10px", style: {
|
|
19
|
+
fill: highlight.isActive ? '#ff6f0057' : color,
|
|
20
|
+
opacity,
|
|
21
|
+
}, ...highlight.onHover }, void 0) }, zone.id));
|
|
22
|
+
}
|
|
23
|
+
exports.default = (0, react_1.memo)(ExclusionZoneAnnotation);
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
26
|
+
const react_1 = require("react");
|
|
27
|
+
const Filters = __importStar(require("../../data/Filters"));
|
|
28
|
+
const ChartContext_1 = require("../context/ChartContext");
|
|
29
|
+
const useSpectraPerNucleus_1 = __importDefault(require("../hooks/useSpectraPerNucleus"));
|
|
30
|
+
const Constants_1 = require("../reducer/core/Constants");
|
|
31
|
+
const ExclusionZoneAnnotation_1 = __importDefault(require("./ExclusionZoneAnnotation"));
|
|
32
|
+
const getVerticalShift_1 = __importDefault(require("./utilities/getVerticalShift"));
|
|
33
|
+
function ExclusionZonesAnnotationsInner({ displayerKey, xDomains, spectra, verticalAlign, }) {
|
|
34
|
+
return ((0, jsx_runtime_1.jsx)("g", { className: "spectrum-exclusion-zones-group", clipPath: `url(#${displayerKey}clip-chart-1d)`, children: spectra
|
|
35
|
+
.filter((d) => d.display.isVisible === true && xDomains[d.id])
|
|
36
|
+
.map((d, index) => getExclusionZones(d).map((zone) => {
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)(ExclusionZoneAnnotation_1.default, { spectrumID: d.id, vAlign: (0, getVerticalShift_1.default)(verticalAlign, { index }), zone: zone, color: d.display.color }, zone.id));
|
|
38
|
+
})) }, void 0));
|
|
39
|
+
}
|
|
40
|
+
const MemoizedPeakAnnotations = (0, react_1.memo)(ExclusionZonesAnnotationsInner);
|
|
41
|
+
function ExclusionZonesAnnotations() {
|
|
42
|
+
const { displayerKey, xDomains, displayerMode, verticalAlign } = (0, ChartContext_1.useChartData)();
|
|
43
|
+
const spectra = (0, useSpectraPerNucleus_1.default)();
|
|
44
|
+
if (displayerMode !== Constants_1.DISPLAYER_MODE.DM_1D)
|
|
45
|
+
return null;
|
|
46
|
+
return ((0, jsx_runtime_1.jsx)(MemoizedPeakAnnotations, { spectra: spectra, displayerKey: displayerKey, xDomains: xDomains, verticalAlign: verticalAlign }, void 0));
|
|
47
|
+
}
|
|
48
|
+
exports.default = ExclusionZonesAnnotations;
|
|
49
|
+
function getExclusionZones(data) {
|
|
50
|
+
return (data.filters.find((filter) => filter.name === Filters.exclusionZones.id)
|
|
51
|
+
?.value || []);
|
|
52
|
+
}
|