nmrium 0.48.0 → 0.49.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/Chart1D.js +1 -1
- package/lib/component/1d/SpectraLegends.js +1 -1
- package/lib/component/1d/Viewer1D.js +144 -124
- package/lib/component/1d/jCouplingGraph/JsCoupling.js +1 -1
- package/lib/component/1d/ranges/Atoms.d.ts +7 -0
- package/lib/component/1d/ranges/Atoms.js +43 -0
- package/lib/component/1d/ranges/Range.js +4 -2
- package/lib/component/1d/tool/BaseLine.d.ts +2 -0
- package/lib/component/1d/tool/BaseLine.js +26 -0
- package/lib/component/1d/tool/BaseLineZones.js +18 -3
- package/lib/component/2d/Chart2D.js +6 -4
- package/lib/component/2d/Viewer2D.js +35 -26
- package/lib/component/context/KeyModifierContext.d.ts +13 -2
- package/lib/component/context/KeyModifierContext.js +35 -4
- package/lib/component/context/LoggerContext.d.ts +9 -0
- package/lib/component/context/LoggerContext.js +21 -7
- package/lib/component/context/PreferencesContext.d.ts +1 -108
- package/lib/component/context/TopicMoleculeContext.d.ts +8 -0
- package/lib/component/context/TopicMoleculeContext.js +30 -0
- package/lib/component/elements/Input.js +4 -1
- package/lib/component/elements/ResizerWithScale.js +19 -2
- package/lib/component/elements/SVGGroup.js +2 -2
- package/lib/component/elements/formik/FormikTextarea.js +8 -9
- package/lib/component/elements/linearAxis/LinearVerticalAxis.js +1 -1
- package/lib/component/elements/resizer/SVGResizer.js +1 -1
- package/lib/component/header/BaseLineCorrectionPanel.js +3 -2
- package/lib/component/header/Header.js +2 -2
- package/lib/component/hooks/useCheckToolsVisibility.js +1 -1
- package/lib/component/hooks/useToolsFunctions.js +4 -2
- package/lib/component/main/InnerNMRium.js +2 -1
- package/lib/component/modal/ExportAsJcampModal.js +1 -1
- package/lib/component/modal/ImportPublicationStringModal.d.ts +2 -1
- package/lib/component/modal/ImportPublicationStringModal.js +76 -32
- package/lib/component/modal/setting/settings-tabs/GeneralTabContent.js +9 -11
- package/lib/component/panels/RangesPanel/RangesTable.js +1 -1
- package/lib/component/panels/SpectrumsPanel/SpectraPreferences.js +39 -5
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +3 -3
- package/lib/component/panels/SpectrumsPanel/SpectrumListPanel.js +4 -2
- package/lib/component/panels/SpectrumsPanel/base/SpectraColumnsManager.js +19 -16
- package/lib/component/reducer/Reducer.js +2 -0
- package/lib/component/reducer/actions/FiltersActions.d.ts +3 -4
- package/lib/component/reducer/actions/FiltersActions.js +92 -55
- package/lib/component/reducer/actions/LoadActions.js +10 -8
- package/lib/component/reducer/actions/SpectrumsActions.d.ts +8 -1
- package/lib/component/reducer/actions/SpectrumsActions.js +3 -3
- package/lib/component/reducer/actions/ToolsActions.d.ts +8 -5
- package/lib/component/reducer/actions/ToolsActions.js +51 -44
- package/lib/component/toolbar/BasicToolBar.js +11 -29
- package/lib/component/utility/export.js +3 -0
- package/lib/component/workspaces/exercise.js +1 -0
- package/lib/component/workspaces/prediction.js +1 -16
- package/lib/component/workspaces/simulation.js +1 -2
- package/lib/component/workspaces/workspaceDefaultProperties.js +4 -3
- package/lib/data/data1d/Spectrum1D/index.d.ts +0 -1
- package/lib/data/data1d/Spectrum1D/index.js +0 -1
- package/lib/versionInfo.js +1 -1
- package/package.json +18 -17
- package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.d.ts +0 -2
- package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.js +0 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { v4 } from '@lukeed/uuid';
|
|
2
2
|
import { current } from 'immer';
|
|
3
3
|
import { xFindClosestIndex } from 'ml-spectra-processing';
|
|
4
|
-
import { Filters, FiltersManager, } from 'nmr-processing';
|
|
4
|
+
import { Filters, FiltersManager, getBaselineZones, } from 'nmr-processing';
|
|
5
5
|
import { defaultApodizationOptions } from '../../../data/constants/DefaultApodizationOptions';
|
|
6
6
|
import { getSlice, isSpectrum2D } from '../../../data/data2d/Spectrum2D';
|
|
7
7
|
import { getProjection } from '../../../data/data2d/Spectrum2D/getMissingProjection';
|
|
@@ -20,12 +20,32 @@ import { setDomain, setMode } from './DomainActions';
|
|
|
20
20
|
import { changeSpectrumVerticalAlignment } from './PreferencesActions';
|
|
21
21
|
import { activateTool, resetSelectedTool } from './ToolsActions';
|
|
22
22
|
const { fft, fftDimension1, fftDimension2, apodization, baselineCorrection, phaseCorrection, zeroFilling, shiftX, shift2DX, shift2DY, exclusionZones, signalProcessing, } = Filters;
|
|
23
|
-
function getFilterUpdateDomainRules(filterName) {
|
|
24
|
-
return (Filters[filterName]?.DOMAIN_UPDATE_RULES ||
|
|
23
|
+
function getFilterUpdateDomainRules(filterName, defaultRule) {
|
|
24
|
+
return (Filters[filterName]?.DOMAIN_UPDATE_RULES ||
|
|
25
|
+
defaultRule || {
|
|
25
26
|
updateXDomain: false,
|
|
26
27
|
updateYDomain: false,
|
|
27
28
|
});
|
|
28
29
|
}
|
|
30
|
+
function getFilterDomain(datum, options) {
|
|
31
|
+
const { startIndex, lastIndex } = options;
|
|
32
|
+
const updateDomainOptions = {
|
|
33
|
+
updateXDomain: false,
|
|
34
|
+
updateYDomain: false,
|
|
35
|
+
};
|
|
36
|
+
if (datum?.filters?.length === 0)
|
|
37
|
+
return updateDomainOptions;
|
|
38
|
+
for (let i = startIndex; i <= lastIndex; i++) {
|
|
39
|
+
const { updateXDomain, updateYDomain } = getFilterUpdateDomainRules(datum.filters[i].name);
|
|
40
|
+
if (!updateDomainOptions.updateXDomain) {
|
|
41
|
+
updateDomainOptions.updateXDomain = updateXDomain;
|
|
42
|
+
}
|
|
43
|
+
if (!updateDomainOptions.updateYDomain) {
|
|
44
|
+
updateDomainOptions.updateYDomain = updateYDomain;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return updateDomainOptions;
|
|
48
|
+
}
|
|
29
49
|
function rollbackSpectrumByFilter(draft, options) {
|
|
30
50
|
const { applyFilter = true, searchBy = 'id', reset = false, key, activeSpectrum, triggerSource = 'none', } = options || {};
|
|
31
51
|
const currentActiveSpectrum = activeSpectrum || getActiveSpectrum(draft);
|
|
@@ -40,47 +60,53 @@ function rollbackSpectrumByFilter(draft, options) {
|
|
|
40
60
|
const datum = draft.data[index];
|
|
41
61
|
previousIsFid = datum.info.isFid;
|
|
42
62
|
const filterIndex = datum.filters.findIndex((f) => f[searchBy] === key);
|
|
43
|
-
const activeFilterId = draft.toolOptions.data.activeFilterID;
|
|
44
63
|
if (filterIndex !== -1 && !reset) {
|
|
45
|
-
const
|
|
64
|
+
const { activeFilterID } = draft.toolOptions.data;
|
|
65
|
+
const activeFilterIndex = activeFilterID
|
|
66
|
+
? datum.filters.findIndex((f) => f.id === activeFilterID)
|
|
67
|
+
: datum.filters.length - 1;
|
|
46
68
|
//set active filter
|
|
47
|
-
draft.toolOptions.data.activeFilterID =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
FiltersManager.reapplyFilters(datum, filters);
|
|
57
|
-
}
|
|
69
|
+
draft.toolOptions.data.activeFilterID =
|
|
70
|
+
datum.filters?.[filterIndex]?.id || null;
|
|
71
|
+
const filters = datum.filters.slice(0, filterIndex || 1);
|
|
72
|
+
updateDomainOptions = getFilterDomain(datum, {
|
|
73
|
+
startIndex: Math.min(activeFilterIndex, filterIndex),
|
|
74
|
+
lastIndex: Math.max(activeFilterIndex, filterIndex),
|
|
75
|
+
});
|
|
76
|
+
FiltersManager.reapplyFilters(datum, filters);
|
|
58
77
|
draft.tempData = current(draft).data;
|
|
59
78
|
// apply the current Filters
|
|
60
79
|
if (applyFilter) {
|
|
61
|
-
|
|
80
|
+
const { name, value } = datum.filters[filterIndex];
|
|
81
|
+
Filters[name].apply(datum, value);
|
|
62
82
|
}
|
|
63
83
|
currentIsFid = datum.info.isFid;
|
|
64
84
|
//if we still point to the same filter then close the filter options panel and reset the selected tool to default one (zoom tool)
|
|
65
|
-
if (
|
|
85
|
+
if (activeFilterID === datum.filters[filterIndex].id &&
|
|
66
86
|
triggerSource === 'Apply') {
|
|
67
87
|
draft.toolOptions.selectedOptionPanel = null;
|
|
68
88
|
draft.toolOptions.selectedTool = 'zoom';
|
|
69
89
|
}
|
|
70
90
|
}
|
|
71
|
-
|
|
91
|
+
if (filterIndex === -1 || reset) {
|
|
92
|
+
if (draft.tempData) {
|
|
93
|
+
FiltersManager.reapplyFilters(datum);
|
|
94
|
+
}
|
|
72
95
|
//if the filter is not exists, create a clone of the current data
|
|
73
96
|
draft.tempData = current(draft).data;
|
|
74
97
|
}
|
|
75
98
|
// re-implement all filters and rest all view property that related to filters
|
|
76
99
|
if (reset) {
|
|
100
|
+
draft.toolOptions.data.activeFilterID = null;
|
|
77
101
|
draft.tempData = null;
|
|
78
|
-
|
|
79
|
-
|
|
102
|
+
if (datum.filters.length > 0 && filterIndex !== -1) {
|
|
103
|
+
updateDomainOptions = getFilterDomain(datum, {
|
|
104
|
+
startIndex: filterIndex,
|
|
105
|
+
lastIndex: datum.filters.length - 1,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
80
108
|
const { toolOptions: { data }, } = getInitialState();
|
|
81
109
|
draft.toolOptions.data = data;
|
|
82
|
-
draft.toolOptions.selectedOptionPanel = null;
|
|
83
|
-
draft.toolOptions.selectedTool = 'zoom';
|
|
84
110
|
currentIsFid = datum.info.isFid;
|
|
85
111
|
}
|
|
86
112
|
}
|
|
@@ -91,28 +117,51 @@ function rollbackSpectrumByFilter(draft, options) {
|
|
|
91
117
|
}
|
|
92
118
|
}
|
|
93
119
|
function rollbackSpectrum(draft, options) {
|
|
94
|
-
const { filterKey, reset = false
|
|
120
|
+
const { filterKey, reset = false } = options;
|
|
95
121
|
//return back the spectra data to point of time before applying a specific filter
|
|
96
|
-
const applyFilter =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
122
|
+
const applyFilter = !filterKey
|
|
123
|
+
? true
|
|
124
|
+
: [
|
|
125
|
+
phaseCorrection.id,
|
|
126
|
+
fft.id,
|
|
127
|
+
shiftX.id,
|
|
128
|
+
shift2DX.id,
|
|
129
|
+
shift2DY.id,
|
|
130
|
+
signalProcessing.id,
|
|
131
|
+
].includes(filterKey);
|
|
132
|
+
beforeRollback(draft, filterKey);
|
|
104
133
|
rollbackSpectrumByFilter(draft, {
|
|
105
134
|
searchBy: 'name',
|
|
106
135
|
key: filterKey,
|
|
107
136
|
applyFilter,
|
|
108
137
|
reset,
|
|
109
138
|
});
|
|
110
|
-
|
|
111
|
-
updateFilterOptionsInView(draft, filterKey);
|
|
112
|
-
}
|
|
139
|
+
afterRollback(draft, filterKey);
|
|
113
140
|
}
|
|
114
|
-
function
|
|
141
|
+
function beforeRollback(draft, filterKey) {
|
|
115
142
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
143
|
+
switch (filterKey) {
|
|
144
|
+
case baselineCorrection.id: {
|
|
145
|
+
if (activeSpectrum) {
|
|
146
|
+
const datum = current(draft).data[activeSpectrum.index];
|
|
147
|
+
const baselineCorrectionFilter = datum.filters.find((filter) => filter.name === Tools.baselineCorrection.id);
|
|
148
|
+
if (!baselineCorrectionFilter ||
|
|
149
|
+
(baselineCorrectionFilter &&
|
|
150
|
+
baselineCorrectionFilter.value.zones?.length === 0)) {
|
|
151
|
+
draft.toolOptions.data.baselineCorrection.zones = getBaselineZones(datum.data);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
draft.toolOptions.data.baselineCorrection.zones =
|
|
155
|
+
baselineCorrectionFilter.value.zones;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
default:
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function afterRollback(draft, filterKey) {
|
|
116
165
|
switch (filterKey) {
|
|
117
166
|
case phaseCorrection.id: {
|
|
118
167
|
// look for the strongest peak to set it as a pivot
|
|
@@ -123,18 +172,6 @@ function updateFilterOptionsInView(draft, filterKey) {
|
|
|
123
172
|
draft.toolOptions.data.pivot = { value: xValue, index };
|
|
124
173
|
break;
|
|
125
174
|
}
|
|
126
|
-
case baselineCorrection.id: {
|
|
127
|
-
if (activeSpectrum) {
|
|
128
|
-
const baselineCorrectionFilter = current(draft).data[activeSpectrum.index].filters.find((filter) => filter.name === Tools.baselineCorrection.id);
|
|
129
|
-
if (baselineCorrectionFilter) {
|
|
130
|
-
draft.toolOptions.data.baselineCorrection.zones =
|
|
131
|
-
baselineCorrectionFilter
|
|
132
|
-
? baselineCorrectionFilter.value.zones
|
|
133
|
-
: [];
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
175
|
case apodization.id: {
|
|
139
176
|
draft.toolOptions.data.apodizationOptions = defaultApodizationOptions;
|
|
140
177
|
break;
|
|
@@ -170,16 +207,17 @@ function disableLivePreview(draft, id) {
|
|
|
170
207
|
const index = activeSpectrum.index;
|
|
171
208
|
const { data } = draft.tempData[index];
|
|
172
209
|
draft.data[index].data = data;
|
|
173
|
-
|
|
210
|
+
if (baselineCorrection.id !== id) {
|
|
211
|
+
setDomain(draft);
|
|
212
|
+
}
|
|
174
213
|
// reset default options
|
|
175
214
|
switch (id) {
|
|
176
|
-
case apodization.
|
|
215
|
+
case apodization.id: {
|
|
177
216
|
draft.toolOptions.data.apodizationOptions = defaultApodizationOptions;
|
|
178
217
|
break;
|
|
179
218
|
}
|
|
180
|
-
default:
|
|
181
|
-
|
|
182
|
-
}
|
|
219
|
+
default:
|
|
220
|
+
break;
|
|
183
221
|
}
|
|
184
222
|
}
|
|
185
223
|
}
|
|
@@ -526,7 +564,7 @@ function calculateBaseLineCorrection(draft, baseLineOptions) {
|
|
|
526
564
|
...draft.toolOptions.data.baselineCorrection,
|
|
527
565
|
...(baseLineOptions && baseLineOptions),
|
|
528
566
|
};
|
|
529
|
-
const { zones, options, livePreview } = draft.toolOptions.data.baselineCorrection;
|
|
567
|
+
const { zones, options, livePreview } = current(draft).toolOptions.data.baselineCorrection;
|
|
530
568
|
if (livePreview) {
|
|
531
569
|
const _data = { data: { x, re, im }, info };
|
|
532
570
|
baselineCorrection.apply(_data, {
|
|
@@ -603,7 +641,6 @@ function handleSetFilterSnapshotHandler(draft, action) {
|
|
|
603
641
|
activateTool(draft, { toolId: filterKey, reset });
|
|
604
642
|
}
|
|
605
643
|
else {
|
|
606
|
-
resetSelectedTool(draft);
|
|
607
644
|
rollbackSpectrum(draft, { filterKey, reset });
|
|
608
645
|
}
|
|
609
646
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { produce } from 'immer';
|
|
1
2
|
import lodashMerge from 'lodash/merge';
|
|
2
3
|
import lodashMergeWith from 'lodash/mergeWith';
|
|
3
4
|
import { buildCorrelationData } from 'nmr-correlation';
|
|
@@ -113,14 +114,15 @@ function initData(draft, action, options = {}) {
|
|
|
113
114
|
const viewState = view;
|
|
114
115
|
if (data?.spectra?.length || forceInitialize) {
|
|
115
116
|
const state = getInitialState();
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
117
|
+
return produce(state, (initialDraft) => {
|
|
118
|
+
setData(initialDraft, action.payload);
|
|
119
|
+
setActiveTab(initialDraft, { tab: viewState?.spectra?.activeTab || '' });
|
|
120
|
+
initialDraft.width = draft.width;
|
|
121
|
+
initialDraft.height = draft.height;
|
|
122
|
+
setPreferences(initialDraft, viewState);
|
|
123
|
+
initialDraft.isLoading = false;
|
|
124
|
+
initialDraft.actionType = action.type;
|
|
125
|
+
});
|
|
124
126
|
}
|
|
125
127
|
else {
|
|
126
128
|
if (view) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Draft } from 'immer';
|
|
2
2
|
import { Spectrum, Display1D, Display2D } from 'nmr-load-save';
|
|
3
|
+
import { NMRRange } from 'nmr-processing';
|
|
3
4
|
import { SpectrumSimulationOptions } from '../../../data/data1d/spectrumSimulation';
|
|
4
5
|
import { Nuclei, Nucleus } from '../../../data/types/common/Nucleus';
|
|
5
6
|
import { State } from '../Reducer';
|
|
@@ -33,7 +34,13 @@ type AlignSpectraAction = ActionType<'ALIGN_SPECTRA', {
|
|
|
33
34
|
targetX: number;
|
|
34
35
|
}>;
|
|
35
36
|
type GenerateSpectrumFromPublicationStringAction = ActionType<'GENERATE_SPECTRUM_FROM_PUBLICATION_STRING', {
|
|
36
|
-
|
|
37
|
+
ranges: NMRRange[];
|
|
38
|
+
info: {
|
|
39
|
+
nucleus: string;
|
|
40
|
+
solvent: string;
|
|
41
|
+
frequency: number;
|
|
42
|
+
name: string;
|
|
43
|
+
};
|
|
37
44
|
}>;
|
|
38
45
|
type ImportSpectraMetaInfoAction = ActionType<'IMPORT_SPECTRA_META_INFO', {
|
|
39
46
|
spectraMeta: Record<string, Record<string, any>>;
|
|
@@ -3,7 +3,7 @@ import lodashGet from 'lodash/get';
|
|
|
3
3
|
import omitBy from 'lodash/omitBy';
|
|
4
4
|
import lodashSet from 'lodash/set';
|
|
5
5
|
import { Filters, FiltersManager } from 'nmr-processing';
|
|
6
|
-
import {
|
|
6
|
+
import { getReferenceShift, isSpectrum1D, get1DColor, initiateDatum1D, generateSpectrumFromRanges, } from '../../../data/data1d/Spectrum1D';
|
|
7
7
|
import { simulateSpectrum, } from '../../../data/data1d/spectrumSimulation';
|
|
8
8
|
import { getMissingProjection, isSpectrum2D, get2DColor, } from '../../../data/data2d/Spectrum2D';
|
|
9
9
|
import { contoursManager } from '../../../data/data2d/Spectrum2D/contours';
|
|
@@ -300,8 +300,8 @@ function handleAlignSpectraHandler(draft, action) {
|
|
|
300
300
|
}
|
|
301
301
|
//action
|
|
302
302
|
function handleGenerateSpectrumFromPublicationStringHandler(draft, action) {
|
|
303
|
-
const
|
|
304
|
-
const spectrum =
|
|
303
|
+
const { ranges, info } = action.payload;
|
|
304
|
+
const spectrum = generateSpectrumFromRanges(ranges, info, draft.usedColors);
|
|
305
305
|
if (spectrum) {
|
|
306
306
|
draft.data.push(spectrum);
|
|
307
307
|
setActiveTab(draft);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Draft } from 'immer';
|
|
2
|
+
import { BaselineCorrectionZone } from 'nmr-processing';
|
|
2
3
|
import { Nucleus } from '../../../data/types/common/Nucleus';
|
|
3
4
|
import { Layout } from '../../2d/utilities/DimensionLayout';
|
|
4
5
|
import { Tool } from '../../toolbar/ToolTypes';
|
|
@@ -25,6 +26,7 @@ type AddBaseLineZoneAction = ActionType<'ADD_BASE_LINE_ZONE', {
|
|
|
25
26
|
startX: number;
|
|
26
27
|
endX: number;
|
|
27
28
|
}>;
|
|
29
|
+
type ResizeBaseLineZoneAction = ActionType<'RESIZE_BASE_LINE_ZONE', BaselineCorrectionZone>;
|
|
28
30
|
type DeleteBaseLineZoneAction = ActionType<'DELETE_BASE_LINE_ZONE', {
|
|
29
31
|
id: string;
|
|
30
32
|
}>;
|
|
@@ -45,18 +47,19 @@ type LevelChangeAction = ActionType<'SET_2D_LEVEL', {
|
|
|
45
47
|
deltaY: number;
|
|
46
48
|
shiftKey: boolean;
|
|
47
49
|
}>;
|
|
48
|
-
export type ToolsActions = ActionType<'TOGGLE_REAL_IMAGINARY_VISIBILITY' | 'RESET_SELECTED_TOOL' | 'SET_SPECTRUMS_VERTICAL_ALIGN' | 'CHANGE_SPECTRUM_DISPLAY_VIEW_MODE' | 'SET_SPECTRA_SAME_TOP' | 'RESET_SPECTRA_SCALE'> | SetSelectedToolAction | AddBaseLineZoneAction | DeleteBaseLineZoneAction | BrushEndAction | ZoomAction | ZoomOutAction | SetActiveTabAction | LevelChangeAction;
|
|
50
|
+
export type ToolsActions = ActionType<'TOGGLE_REAL_IMAGINARY_VISIBILITY' | 'RESET_SELECTED_TOOL' | 'SET_SPECTRUMS_VERTICAL_ALIGN' | 'CHANGE_SPECTRUM_DISPLAY_VIEW_MODE' | 'SET_SPECTRA_SAME_TOP' | 'RESET_SPECTRA_SCALE'> | SetSelectedToolAction | AddBaseLineZoneAction | DeleteBaseLineZoneAction | ResizeBaseLineZoneAction | BrushEndAction | ZoomAction | ZoomOutAction | SetActiveTabAction | LevelChangeAction;
|
|
49
51
|
declare function handleResetSelectedTool(draft: Draft<State>): void;
|
|
50
|
-
declare function resetSelectedTool(draft: Draft<State
|
|
52
|
+
declare function resetSelectedTool(draft: Draft<State>): void;
|
|
51
53
|
interface ActivateToolOptions {
|
|
52
|
-
toolId:
|
|
54
|
+
toolId: Tool;
|
|
53
55
|
reset?: boolean;
|
|
54
56
|
}
|
|
55
|
-
declare function activateTool(draft:
|
|
57
|
+
declare function activateTool(draft: Draft<State>, options: ActivateToolOptions): void;
|
|
56
58
|
declare function setSelectedTool(draft: Draft<State>, action: SetSelectedToolAction): void;
|
|
57
59
|
declare function setSpectrumsVerticalAlign(draft: Draft<State>): void;
|
|
58
60
|
declare function handleChangeSpectrumDisplayMode(draft: Draft<State>): void;
|
|
59
61
|
declare function handleAddBaseLineZone(draft: Draft<State>, action: AddBaseLineZoneAction): void;
|
|
62
|
+
declare function handleResizeBaseLineZone(draft: Draft<State>, action: ResizeBaseLineZoneAction): void;
|
|
60
63
|
declare function handleDeleteBaseLineZone(draft: Draft<State>, action: DeleteBaseLineZoneAction): void;
|
|
61
64
|
declare function handleToggleRealImaginaryVisibility(draft: Draft<State>): void;
|
|
62
65
|
declare function handleBrushEnd(draft: Draft<State>, action: BrushEndAction): void;
|
|
@@ -69,4 +72,4 @@ declare function handelSetActiveTab(draft: Draft<State>, action: SetActiveTabAct
|
|
|
69
72
|
declare function levelChangeHandler(draft: Draft<State>, action: LevelChangeAction): void;
|
|
70
73
|
declare function setSpectraSameTopHandler(draft: Draft<State>): void;
|
|
71
74
|
declare function resetSpectraScale(draft: Draft<State>): void;
|
|
72
|
-
export { handleResetSelectedTool, resetSelectedTool, setSelectedTool, activateTool, setSpectrumsVerticalAlign, handleChangeSpectrumDisplayMode, handleAddBaseLineZone, handleDeleteBaseLineZone, handleToggleRealImaginaryVisibility, handleBrushEnd, handleZoom, zoomOut, handelSetActiveTab, levelChangeHandler, setActiveTab, setTab, setSpectraSameTopHandler, resetSpectraScale, setMargin, };
|
|
75
|
+
export { handleResetSelectedTool, resetSelectedTool, setSelectedTool, activateTool, setSpectrumsVerticalAlign, handleChangeSpectrumDisplayMode, handleAddBaseLineZone, handleDeleteBaseLineZone, handleResizeBaseLineZone, handleToggleRealImaginaryVisibility, handleBrushEnd, handleZoom, zoomOut, handelSetActiveTab, levelChangeHandler, setActiveTab, setTab, setSpectraSameTopHandler, resetSpectraScale, setMargin, };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { v4 } from '@lukeed/uuid';
|
|
2
|
-
import { original } from 'immer';
|
|
3
2
|
import { contoursManager } from '../../../data/data2d/Spectrum2D/contours';
|
|
4
3
|
import { getYScale, getXScale } from '../../1d/utilities/scale';
|
|
5
4
|
import { LAYOUT } from '../../2d/utilities/DimensionLayout';
|
|
@@ -18,10 +17,10 @@ import { getVerticalAlign } from '../helper/getVerticalAlign';
|
|
|
18
17
|
import { setIntegralsViewProperty } from '../helper/setIntegralsViewProperty';
|
|
19
18
|
import { setRangesViewProperty } from '../helper/setRangesViewProperty';
|
|
20
19
|
import { setDomain, setMode } from './DomainActions';
|
|
21
|
-
import { calculateBaseLineCorrection,
|
|
20
|
+
import { calculateBaseLineCorrection, rollbackSpectrum, } from './FiltersActions';
|
|
22
21
|
import { changeSpectrumVerticalAlignment } from './PreferencesActions';
|
|
23
22
|
function resetTool(draft, options = {}) {
|
|
24
|
-
const { resetToDefaultTool = true, resetFiltersOptionPanel = true, defaultToolId = 'zoom',
|
|
23
|
+
const { resetToDefaultTool = true, resetFiltersOptionPanel = true, defaultToolId = 'zoom', reset, toolId, } = options;
|
|
25
24
|
// reset temp range
|
|
26
25
|
if (resetFiltersOptionPanel) {
|
|
27
26
|
draft.toolOptions.selectedOptionPanel = null;
|
|
@@ -29,58 +28,58 @@ function resetTool(draft, options = {}) {
|
|
|
29
28
|
if (resetToDefaultTool) {
|
|
30
29
|
draft.toolOptions.selectedTool = defaultToolId;
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
let rollOptions = { reset: true };
|
|
32
|
+
if (toolId && Tools?.[toolId]?.isFilter) {
|
|
33
|
+
rollOptions = { filterKey: toolId, reset };
|
|
35
34
|
}
|
|
35
|
+
rollbackSpectrum(draft, rollOptions);
|
|
36
36
|
}
|
|
37
37
|
function handleResetSelectedTool(draft) {
|
|
38
38
|
resetSelectedTool(draft);
|
|
39
39
|
}
|
|
40
|
-
function resetSelectedTool(draft
|
|
41
|
-
if (
|
|
42
|
-
Tools[draft.toolOptions.selectedTool].isFilter)
|
|
43
|
-
|
|
44
|
-
resetTool(draft, { resetSpectrum: true });
|
|
40
|
+
function resetSelectedTool(draft) {
|
|
41
|
+
if (draft.toolOptions.selectedTool &&
|
|
42
|
+
Tools[draft.toolOptions.selectedTool].isFilter) {
|
|
43
|
+
resetTool(draft, { reset: true, toolId: draft.toolOptions.selectedTool });
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
//utility
|
|
48
47
|
function activateTool(draft, options) {
|
|
49
48
|
const { toolId, reset = false } = options;
|
|
50
|
-
if (draft?.data.length
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
draft.
|
|
72
|
-
if (
|
|
73
|
-
|
|
49
|
+
if (draft?.data.length === 0) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (!toolId || toolId !== draft.toolOptions.selectedTool || reset) {
|
|
53
|
+
resetTool(draft, { resetToDefaultTool: false, toolId, reset });
|
|
54
|
+
}
|
|
55
|
+
if (!toolId || reset) {
|
|
56
|
+
draft.toolOptions.selectedOptionPanel = null;
|
|
57
|
+
draft.toolOptions.selectedTool = 'zoom';
|
|
58
|
+
draft.toolOptions.data.activeFilterID = null;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
draft.toolOptions.selectedTool = toolId;
|
|
62
|
+
if (Tools[toolId]?.hasOptionPanel) {
|
|
63
|
+
draft.toolOptions.selectedOptionPanel = toolId;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// start Range edit mode
|
|
67
|
+
if (toolId === Tools.editRange.id) {
|
|
68
|
+
const activeSpectrum = getActiveSpectrum(draft);
|
|
69
|
+
if (activeSpectrum) {
|
|
70
|
+
const range = draft.view.ranges?.[activeSpectrum?.id];
|
|
71
|
+
if (range) {
|
|
72
|
+
range.showMultiplicityTrees = true;
|
|
74
73
|
}
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
else {
|
|
75
|
+
draft.view.ranges[activeSpectrum.id] = {
|
|
76
|
+
...defaultRangesViewState,
|
|
77
|
+
showMultiplicityTrees: true,
|
|
78
|
+
};
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
|
-
else {
|
|
80
|
-
resetTool(draft, { resetToDefaultTool: false });
|
|
81
|
-
}
|
|
82
|
-
setMargin(draft);
|
|
83
81
|
}
|
|
82
|
+
setMargin(draft);
|
|
84
83
|
}
|
|
85
84
|
function setSelectedTool(draft, action) {
|
|
86
85
|
const { selectedTool } = action.payload;
|
|
@@ -128,11 +127,19 @@ function handleAddBaseLineZone(draft, action) {
|
|
|
128
127
|
draft.toolOptions.data.baselineCorrection.zones = zones.slice();
|
|
129
128
|
calculateBaseLineCorrection(draft);
|
|
130
129
|
}
|
|
130
|
+
function handleResizeBaseLineZone(draft, action) {
|
|
131
|
+
const { from, to, id } = action.payload;
|
|
132
|
+
const zones = draft.toolOptions.data.baselineCorrection.zones;
|
|
133
|
+
const zoneIndex = zones.findIndex((zone) => zone.id === id);
|
|
134
|
+
if (zoneIndex !== -1) {
|
|
135
|
+
zones[zoneIndex] = { id, from, to };
|
|
136
|
+
}
|
|
137
|
+
calculateBaseLineCorrection(draft);
|
|
138
|
+
}
|
|
131
139
|
function handleDeleteBaseLineZone(draft, action) {
|
|
132
140
|
const { id } = action.payload;
|
|
133
|
-
const state = original(draft);
|
|
134
141
|
draft.toolOptions.data.baselineCorrection.zones =
|
|
135
|
-
|
|
142
|
+
draft.toolOptions.data.baselineCorrection.zones.filter((zone) => zone.id !== id);
|
|
136
143
|
calculateBaseLineCorrection(draft);
|
|
137
144
|
}
|
|
138
145
|
function handleToggleRealImaginaryVisibility(draft) {
|
|
@@ -437,4 +444,4 @@ function resetSpectraScale(draft) {
|
|
|
437
444
|
draft.yDomain = draft.originDomain.yDomain;
|
|
438
445
|
setZoom(draft, { scale: 0.8 });
|
|
439
446
|
}
|
|
440
|
-
export { handleResetSelectedTool, resetSelectedTool, setSelectedTool, activateTool, setSpectrumsVerticalAlign, handleChangeSpectrumDisplayMode, handleAddBaseLineZone, handleDeleteBaseLineZone, handleToggleRealImaginaryVisibility, handleBrushEnd, handleZoom, zoomOut, handelSetActiveTab, levelChangeHandler, setActiveTab, setTab, setSpectraSameTopHandler, resetSpectraScale, setMargin, };
|
|
447
|
+
export { handleResetSelectedTool, resetSelectedTool, setSelectedTool, activateTool, setSpectrumsVerticalAlign, handleChangeSpectrumDisplayMode, handleAddBaseLineZone, handleDeleteBaseLineZone, handleResizeBaseLineZone, handleToggleRealImaginaryVisibility, handleBrushEnd, handleZoom, zoomOut, handelSetActiveTab, levelChangeHandler, setActiveTab, setTab, setSpectraSameTopHandler, resetSpectraScale, setMargin, };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { SvgNmrRealImag, SvgNmrOverlay3, SvgNmrOverlay3Aligned, SvgNmrAlignBottom, SvgNmrAlignCenter, } from 'cheminfo-font';
|
|
3
|
-
import {
|
|
3
|
+
import { memo } from 'react';
|
|
4
4
|
import { FaDownload, FaFileDownload, FaFileImage, FaCopy, FaFileExport, FaFile, FaFileImport, } from 'react-icons/fa';
|
|
5
5
|
import { Toolbar, useOnOff } from 'react-science/ui';
|
|
6
6
|
import { useChartData } from '../context/ChartContext';
|
|
7
7
|
import { useLoader } from '../context/LoaderContext';
|
|
8
8
|
import { DropdownMenu } from '../elements/DropdownMenu';
|
|
9
|
-
import { useModal } from '../elements/popup/Modal';
|
|
10
9
|
import useCheckExperimentalFeature from '../hooks/useCheckExperimentalFeature';
|
|
11
10
|
import { useCheckToolsVisibility } from '../hooks/useCheckToolsVisibility';
|
|
12
11
|
import useDatumWithSpectraStatistics from '../hooks/useDatumWithSpectraStatistics';
|
|
@@ -34,7 +33,7 @@ const IMPORT_MENU = [
|
|
|
34
33
|
},
|
|
35
34
|
{
|
|
36
35
|
icon: _jsx(FaFile, {}),
|
|
37
|
-
text: '
|
|
36
|
+
text: 'Generate spectrum from publication string',
|
|
38
37
|
data: {
|
|
39
38
|
id: 'importPublicationString',
|
|
40
39
|
},
|
|
@@ -92,12 +91,12 @@ const EXPORT_MENU = [
|
|
|
92
91
|
},
|
|
93
92
|
];
|
|
94
93
|
function BasicToolBarInner({ verticalAlign, ftCounter, fidCounter, }) {
|
|
95
|
-
const modal = useModal();
|
|
96
94
|
const openLoader = useLoader();
|
|
97
95
|
const openMetaInformationModal = useMetaInformationImportationModal();
|
|
98
96
|
const isExperimentalFeature = useCheckExperimentalFeature();
|
|
99
97
|
const isButtonVisible = useCheckToolsVisibility();
|
|
100
|
-
const [
|
|
98
|
+
const [isLoadJCAMPModalOpened, openLoadJCAMPModal, closeLoadJCAMPModal] = useOnOff(false);
|
|
99
|
+
const [isPublicationStringModalOpened, openPublicationStringModal, closePublicationStringModal,] = useOnOff(false);
|
|
101
100
|
const importMenu = isExperimentalFeature
|
|
102
101
|
? IMPORT_MENU
|
|
103
102
|
: IMPORT_MENU.filter((item) => item.id !== 'importPublicationString');
|
|
@@ -106,35 +105,24 @@ function BasicToolBarInner({ verticalAlign, ftCounter, fidCounter, }) {
|
|
|
106
105
|
: EXPORT_MENU.filter((item) => item.id !== 'nmre');
|
|
107
106
|
const { isRealSpectrumShown, changeSpectrumViewHandler, changeDisplayViewModeHandler, alignSpectrumsVerticallyHandler, } = useToolsFunctions();
|
|
108
107
|
const { saveAsSVGHandler, saveAsPNGHandler, saveAsJSONHandler, saveToClipboardHandler, saveAsHandler, } = useExport();
|
|
109
|
-
|
|
110
|
-
openLoadModal();
|
|
111
|
-
}, [openLoadModal]);
|
|
112
|
-
const openImportPublicationStringModal = useCallback(() => {
|
|
113
|
-
modal.show(_jsx(ImportPublicationStringModal, { onClose: () => modal.close() }), {});
|
|
114
|
-
}, [modal]);
|
|
115
|
-
const importHandler = useCallback((data) => {
|
|
108
|
+
function importHandler(data) {
|
|
116
109
|
switch (data?.id) {
|
|
117
110
|
case 'importFile':
|
|
118
111
|
openLoader();
|
|
119
112
|
break;
|
|
120
113
|
case 'importJDX':
|
|
121
|
-
|
|
114
|
+
openLoadJCAMPModal();
|
|
122
115
|
break;
|
|
123
116
|
case 'importPublicationString':
|
|
124
|
-
|
|
117
|
+
openPublicationStringModal();
|
|
125
118
|
break;
|
|
126
119
|
case 'importMetaInformation':
|
|
127
120
|
openMetaInformationModal();
|
|
128
121
|
break;
|
|
129
122
|
default:
|
|
130
123
|
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
importJCAMPFile,
|
|
134
|
-
openImportPublicationStringModal,
|
|
135
|
-
openMetaInformationModal,
|
|
136
|
-
]);
|
|
137
|
-
const exportHandler = useCallback((data) => {
|
|
124
|
+
}
|
|
125
|
+
function exportHandler(data) {
|
|
138
126
|
switch (data?.id) {
|
|
139
127
|
case 'svg':
|
|
140
128
|
void saveAsSVGHandler();
|
|
@@ -154,14 +142,8 @@ function BasicToolBarInner({ verticalAlign, ftCounter, fidCounter, }) {
|
|
|
154
142
|
default:
|
|
155
143
|
break;
|
|
156
144
|
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
saveAsPNGHandler,
|
|
160
|
-
saveAsJSONHandler,
|
|
161
|
-
saveAsHandler,
|
|
162
|
-
saveToClipboardHandler,
|
|
163
|
-
]);
|
|
164
|
-
return (_jsxs(Fragment, { children: [_jsx(LoadJCAMPModal, { isOpen: isLoadModalOpened, onCloseDialog: closeLoadModal }), isButtonVisible('import') && (_jsx(DropdownMenu, { placement: "right-start", onSelect: (data) => {
|
|
145
|
+
}
|
|
146
|
+
return (_jsxs(_Fragment, { children: [_jsx(LoadJCAMPModal, { isOpen: isLoadJCAMPModalOpened, onCloseDialog: closeLoadJCAMPModal }), _jsx(ImportPublicationStringModal, { isOpen: isPublicationStringModalOpened, onClose: closePublicationStringModal }), isButtonVisible('import') && (_jsx(DropdownMenu, { placement: "right-start", onSelect: (data) => {
|
|
165
147
|
importHandler(data);
|
|
166
148
|
}, targetTagName: "div", targetProps: { style: { flex: 'none' } }, options: importMenu, children: _jsx(Toolbar.Item, { id: options.import.id, title: options.import.label, icon: _jsx(FaFileImport, {}) }) })), isButtonVisible('exportAs') && (_jsx(DropdownMenu, { onSelect: (data) => {
|
|
167
149
|
exportHandler(data);
|
|
@@ -186,6 +186,9 @@ function getBlob(rootRef, elementID, css) {
|
|
|
186
186
|
const floatingMoleculesGroup = getMoleculesElement(rootRef);
|
|
187
187
|
_svg.append(floatingMoleculesGroup);
|
|
188
188
|
const nmrCss = `
|
|
189
|
+
* {
|
|
190
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
191
|
+
}
|
|
189
192
|
.grid line,.grid path{stroke:none;} .peaks-text{fill:#730000} .x path{stroke-width:1px} .x text{
|
|
190
193
|
font-size: 12px;
|
|
191
194
|
font-weight: bold;
|