nmrium 0.19.1 → 0.21.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 +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 +106 -80
- package/lib/component/NMRium.d.ts +8 -3
- package/lib/component/NMRium.js +36 -33
- package/lib/component/elements/NumberInput.d.ts +1 -2
- package/lib/component/elements/Tab/Tab.js +1 -0
- package/lib/component/header/Header.js +10 -3
- package/lib/component/hooks/useActiveSpectrumStyleOptions.d.ts +6 -0
- package/lib/component/hooks/useActiveSpectrumStyleOptions.js +15 -0
- package/lib/component/hooks/useCheckExperimentalFeature.js +2 -1
- package/lib/component/hooks/useCheckToolsVisibility.d.ts +1 -0
- package/lib/component/hooks/useCheckToolsVisibility.js +6 -0
- package/lib/component/hooks/useToolsFunctions.js +2 -1
- package/lib/component/hooks/useXYReduce.d.ts +2 -1
- package/lib/component/loader/DropZone.js +88 -88
- 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/modal/changeSum/ChangeSumModal.js +4 -2
- package/lib/component/modal/setting/DisplayTabContent.js +1 -1
- package/lib/component/modal/setting/GeneralSettings.js +1 -5
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +0 -3
- package/lib/component/panels/IntegralsPanel/IntegralsPreferences.js +4 -17
- 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/PeaksPanel/PeaksPanel.js +0 -3
- package/lib/component/panels/PeaksPanel/PeaksPreferences.js +5 -14
- package/lib/component/panels/RangesPanel/RangesPanel.js +0 -3
- package/lib/component/panels/RangesPanel/RangesPreferences.js +5 -18
- package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +13 -3
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DHistogram.js +1 -1
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/MoveLink.d.ts +5 -5
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +1 -1
- package/lib/component/panels/SummaryPanel/Utilities.d.ts +7 -7
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +0 -3
- package/lib/component/panels/ZonesPanel/ZonesPreferences.js +5 -18
- package/lib/component/panels/ZonesPanel/ZonesTable.js +9 -2
- package/lib/component/panels/databasePanel/DatabasePanel.js +0 -3
- package/lib/component/panels/databasePanel/DatabasePreferences.js +4 -17
- package/lib/component/reducer/Reducer.d.ts +11 -27
- package/lib/component/reducer/Reducer.js +4 -5
- package/lib/component/reducer/actions/CorrelationsActions.d.ts +7 -7
- package/lib/component/reducer/actions/CorrelationsActions.js +1 -1
- 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 +13 -59
- package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +1 -0
- package/lib/component/reducer/helper/ZoomHistoryManager.js +2 -1
- package/lib/component/reducer/helper/getRange.d.ts +6 -1
- package/lib/component/reducer/helper/getRange.js +1 -1
- package/lib/component/reducer/preferencesReducer.d.ts +2 -0
- package/lib/component/reducer/preferencesReducer.js +76 -36
- package/lib/component/toolbar/FunctionToolBar.js +9 -15
- package/lib/component/toolbar/ToolTypes.js +3 -3
- 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/component/workspaces/Workspace.d.ts +6 -0
- package/lib/component/workspaces/Workspace.js +1 -0
- package/lib/component/workspaces/basic.d.ts +2 -0
- package/lib/component/workspaces/basic.js +45 -0
- package/lib/component/workspaces/exercise1D.d.ts +2 -0
- package/lib/component/workspaces/exercise1D.js +45 -0
- package/lib/component/workspaces/index.d.ts +6 -0
- package/lib/component/workspaces/index.js +4 -0
- package/lib/component/workspaces/process1D.d.ts +2 -0
- package/lib/component/workspaces/process1D.js +43 -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/migration/MigrationManager.js +3 -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 +106 -80
- package/lib-cjs/component/NMRium.js +37 -34
- package/lib-cjs/component/elements/Tab/Tab.js +1 -0
- package/lib-cjs/component/header/Header.js +10 -3
- package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +21 -0
- package/lib-cjs/component/hooks/useCheckExperimentalFeature.js +5 -1
- package/lib-cjs/component/hooks/useCheckToolsVisibility.js +13 -0
- package/lib-cjs/component/hooks/useToolsFunctions.js +2 -1
- package/lib-cjs/component/loader/DropZone.js +88 -88
- 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/modal/changeSum/ChangeSumModal.js +4 -2
- package/lib-cjs/component/modal/setting/DisplayTabContent.js +1 -1
- package/lib-cjs/component/modal/setting/GeneralSettings.js +1 -5
- package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +0 -3
- package/lib-cjs/component/panels/IntegralsPanel/IntegralsPreferences.js +3 -16
- 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/PeaksPanel/PeaksPanel.js +0 -3
- package/lib-cjs/component/panels/PeaksPanel/PeaksPreferences.js +4 -13
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +0 -3
- package/lib-cjs/component/panels/RangesPanel/RangesPreferences.js +4 -17
- package/lib-cjs/component/panels/SpectrumsPanel/SpectraPanelHeader.js +13 -3
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum2DHistogram.js +1 -1
- package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +0 -3
- package/lib-cjs/component/panels/ZonesPanel/ZonesPreferences.js +4 -17
- package/lib-cjs/component/panels/ZonesPanel/ZonesTable.js +8 -1
- package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +0 -3
- package/lib-cjs/component/panels/databasePanel/DatabasePreferences.js +3 -16
- 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 +13 -61
- package/lib-cjs/component/reducer/helper/ZoomHistoryManager.js +2 -1
- package/lib-cjs/component/reducer/helper/getRange.js +1 -1
- package/lib-cjs/component/reducer/preferencesReducer.js +75 -35
- package/lib-cjs/component/toolbar/FunctionToolBar.js +9 -15
- package/lib-cjs/component/toolbar/ToolTypes.js +3 -3
- package/lib-cjs/component/utility/PathBuilder.js +21 -0
- package/lib-cjs/component/utility/getSpectraByNucleus.js +11 -0
- package/lib-cjs/component/workspaces/Workspace.js +2 -0
- package/lib-cjs/component/workspaces/basic.js +48 -0
- package/lib-cjs/component/workspaces/exercise1D.js +48 -0
- package/lib-cjs/component/workspaces/index.js +6 -0
- package/lib-cjs/component/workspaces/process1D.js +46 -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/migration/MigrationManager.js +3 -0
- package/lib-cjs/data/types/data1d/ExclusionZone.js +2 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +28 -29
- 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/component/nmriumMode/basic.d.ts +0 -38
- package/lib/component/nmriumMode/basic.js +0 -37
- package/lib/component/nmriumMode/exercise1D.d.ts +0 -38
- package/lib/component/nmriumMode/exercise1D.js +0 -37
- package/lib/component/nmriumMode/process1D.d.ts +0 -38
- package/lib/component/nmriumMode/process1D.js +0 -37
- package/lib-cjs/component/1d/ExclusionZone.js +0 -32
- package/lib-cjs/component/1d/ExclusionZones.js +0 -16
- package/lib-cjs/component/nmriumMode/basic.js +0 -39
- package/lib-cjs/component/nmriumMode/exercise1D.js +0 -39
- package/lib-cjs/component/nmriumMode/process1D.js +0 -39
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { Draft } from 'immer';
|
|
2
|
-
import {
|
|
2
|
+
import { Tolerance, Options as CorrelationOptions, Correlation, Values as CorrelationValues } from 'nmr-correlation';
|
|
3
3
|
import { State } from '../Reducer';
|
|
4
4
|
declare function handleUpdateCorrelations(draft: Draft<State>): void;
|
|
5
5
|
declare function handleSetMF(draft: Draft<State>, payload: {
|
|
6
6
|
mf: string;
|
|
7
7
|
}): void;
|
|
8
8
|
declare function handleSetTolerance(draft: Draft<State>, payload: {
|
|
9
|
-
tolerance:
|
|
9
|
+
tolerance: Tolerance;
|
|
10
10
|
}): void;
|
|
11
11
|
declare function handleSetCorrelation(draft: Draft<State>, payload: {
|
|
12
12
|
id: string;
|
|
13
|
-
correlation:
|
|
14
|
-
options:
|
|
13
|
+
correlation: Correlation;
|
|
14
|
+
options: CorrelationOptions;
|
|
15
15
|
}): void;
|
|
16
16
|
declare function handleSetCorrelations(draft: Draft<State>, payload: {
|
|
17
|
-
correlations:
|
|
18
|
-
options:
|
|
17
|
+
correlations: CorrelationValues;
|
|
18
|
+
options: CorrelationOptions;
|
|
19
19
|
}): void;
|
|
20
20
|
declare function handleDeleteCorrelation(draft: Draft<State>, payload: {
|
|
21
|
-
correlation:
|
|
21
|
+
correlation: Correlation;
|
|
22
22
|
assignmentData: any;
|
|
23
23
|
}): void;
|
|
24
24
|
export { handleDeleteCorrelation, handleSetCorrelation, handleSetCorrelations, handleSetMF, handleSetTolerance, handleUpdateCorrelations, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { original } from 'immer';
|
|
2
2
|
import lodashCloneDeep from 'lodash/cloneDeep';
|
|
3
|
-
import { buildCorrelationData, setCorrelation } from 'nmr-correlation';
|
|
3
|
+
import { buildCorrelationData, setCorrelation, } from 'nmr-correlation';
|
|
4
4
|
import { findRange, findSignal1D, findSignal2D, findSpectrum, findZone, } from '../../../data/utilities/FindUtilities';
|
|
5
5
|
import { handleDeleteSignal as handleDeleteSignal1D } from './RangesActions';
|
|
6
6
|
import { handleDeleteSignal as handleDeleteSignal2D } from './ZonesActions';
|
|
@@ -29,4 +29,6 @@ declare function resetSpectrumByFilter(draft: any, id?: string | null, options?:
|
|
|
29
29
|
}, activeSpectrum?: ActiveSpectrum | null): any;
|
|
30
30
|
declare function filterSnapshotHandler(draft: Draft<State>, action: any): void;
|
|
31
31
|
declare function handleMultipleSpectraFilter(draft: Draft<State>, action: any): void;
|
|
32
|
-
|
|
32
|
+
declare function handleAddExclusionZone(draft: Draft<State>, action: any): void;
|
|
33
|
+
declare function handleDeleteExclusionZone(draft: Draft<State>, action: any): void;
|
|
34
|
+
export { shiftSpectrumAlongXAxis, applyZeroFillingFilter, applyFFTFilter, applyManualPhaseCorrectionFilter, applyAutoPhaseCorrectionFilter, applyAbsoluteFilter, calculateManualPhaseCorrection, handleMultipleSpectraFilter, enableFilter, deleteFilter, deleteSpectraFilter, handleBaseLineCorrectionFilter, filterSnapshotHandler, resetSpectrumByFilter, handleAddExclusionZone, handleDeleteExclusionZone, };
|
|
@@ -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, };
|
|
@@ -180,7 +180,7 @@ function handleBrushEnd(draft, action) {
|
|
|
180
180
|
break;
|
|
181
181
|
}
|
|
182
182
|
if (brushHistory) {
|
|
183
|
-
brushHistory.push({ xDomain:
|
|
183
|
+
brushHistory.push({ xDomain: draft.xDomain, yDomain: draft.yDomain });
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
else {
|
|
@@ -242,6 +242,7 @@ function zoomOut(draft, action) {
|
|
|
242
242
|
switch (zoomType) {
|
|
243
243
|
case ZoomType.HORIZONTAL: {
|
|
244
244
|
draft.xDomain = draft.originDomain.xDomain;
|
|
245
|
+
zoomHistory.clear();
|
|
245
246
|
break;
|
|
246
247
|
}
|
|
247
248
|
case ZoomType.VERTICAL:
|
|
@@ -264,34 +265,16 @@ function zoomOut(draft, action) {
|
|
|
264
265
|
}
|
|
265
266
|
else {
|
|
266
267
|
const { xDomain, yDomain, yDomains } = draft.originDomain;
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
const activeSpectrum = draft.tabActiveSpectrum[draft.activeTab.split(',')[1]];
|
|
278
|
-
draft.yDomain = yDomain;
|
|
279
|
-
if (activeSpectrum?.id) {
|
|
280
|
-
draft.yDomains[activeSpectrum.id] = yDomains[activeSpectrum.id];
|
|
281
|
-
}
|
|
282
|
-
break;
|
|
283
|
-
}
|
|
284
|
-
case LAYOUT.CENTER_2D: {
|
|
285
|
-
const zoomValue = zoomHistory.pop();
|
|
286
|
-
draft.xDomain = zoomValue ? zoomValue.xDomain : xDomain;
|
|
287
|
-
draft.yDomain = zoomValue ? zoomValue.yDomain : yDomain;
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
default:
|
|
291
|
-
draft.xDomain = xDomain;
|
|
292
|
-
draft.yDomain = yDomain;
|
|
293
|
-
draft.yDomains = yDomains;
|
|
294
|
-
break;
|
|
268
|
+
if ([LAYOUT.TOP_1D, LAYOUT.LEFT_1D, LAYOUT.CENTER_2D].includes(trackID)) {
|
|
269
|
+
const zoomValue = zoomHistory.pop();
|
|
270
|
+
draft.xDomain = zoomValue ? zoomValue.xDomain : xDomain;
|
|
271
|
+
draft.yDomain = zoomValue ? zoomValue.yDomain : yDomain;
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
zoomHistory.clear();
|
|
275
|
+
draft.xDomain = xDomain;
|
|
276
|
+
draft.yDomain = yDomain;
|
|
277
|
+
draft.yDomains = yDomains;
|
|
295
278
|
}
|
|
296
279
|
}
|
|
297
280
|
}
|
|
@@ -450,33 +433,4 @@ function resetSpectraScale(draft) {
|
|
|
450
433
|
draft.yDomain = draft.originDomain.yDomain;
|
|
451
434
|
setZoom(draft, { scale: 0.8 });
|
|
452
435
|
}
|
|
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, };
|
|
436
|
+
export { resetSelectedTool, setSelectedTool, setSelectedOptionPanel, setSpectrumsVerticalAlign, handleChangeSpectrumDisplayMode, handleAddBaseLineZone, handleDeleteBaseLineZone, handleToggleRealImaginaryVisibility, handleBrushEnd, setVerticalIndicatorXPosition, handleZoom, zoomOut, handelSetActiveTab, levelChangeHandler, setActiveTab, setTab, setSpectraSameTopHandler, resetSpectraScale, };
|
|
@@ -10,6 +10,7 @@ interface ZoomHistoryManager {
|
|
|
10
10
|
push: (value: HistoryItem) => void;
|
|
11
11
|
pop: () => HistoryItem;
|
|
12
12
|
getLast: () => HistoryItem;
|
|
13
|
+
clear: () => void;
|
|
13
14
|
}
|
|
14
15
|
export default function zoomHistoryManager(zoomHistory: ZoomHistory, nucleus: string): ZoomHistoryManager;
|
|
15
16
|
export {};
|
|
@@ -5,7 +5,8 @@ export default function zoomHistoryManager(zoomHistory, nucleus) {
|
|
|
5
5
|
const push = preparePush(zoomHistory[nucleus]);
|
|
6
6
|
const pop = preparePop(zoomHistory[nucleus]);
|
|
7
7
|
const getLast = prepareGetLast(zoomHistory[nucleus]);
|
|
8
|
-
|
|
8
|
+
const clear = () => (zoomHistory[nucleus] = []);
|
|
9
|
+
return { historyStack: zoomHistory[nucleus], push, pop, getLast, clear };
|
|
9
10
|
}
|
|
10
11
|
function preparePush(historyStack) {
|
|
11
12
|
return (val) => {
|
|
@@ -22,6 +22,7 @@ export interface PreferencesState {
|
|
|
22
22
|
panels: any;
|
|
23
23
|
};
|
|
24
24
|
dispatch: any;
|
|
25
|
+
workspace: string;
|
|
25
26
|
}
|
|
26
27
|
export declare const preferencesInitialState: PreferencesState;
|
|
27
28
|
declare const preferencesReducer: (base: {
|
|
@@ -45,5 +46,6 @@ declare const preferencesReducer: (base: {
|
|
|
45
46
|
readonly panels: any;
|
|
46
47
|
};
|
|
47
48
|
readonly dispatch: any;
|
|
49
|
+
readonly workspace: string;
|
|
48
50
|
}, action: any) => import("immer/dist/internal").WritableDraft<PreferencesState>;
|
|
49
51
|
export default preferencesReducer;
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import { produce } from 'immer';
|
|
2
2
|
import lodashMerge from 'lodash/merge';
|
|
3
|
-
import {
|
|
4
|
-
import basic from '../nmriumMode/basic';
|
|
5
|
-
import exercise1D from '../nmriumMode/exercise1D';
|
|
6
|
-
import process1D from '../nmriumMode/process1D';
|
|
3
|
+
import { NMRiumWorkspaces } from '../NMRium';
|
|
7
4
|
import { getLocalStorage, removeData, storeData, } from '../utility/LocalStorage';
|
|
5
|
+
import workspaces from '../workspaces';
|
|
8
6
|
export const INIT_PREFERENCES = 'INIT_PREFERENCES';
|
|
9
7
|
export const SET_PREFERENCES = 'SET_PREFERENCES';
|
|
10
8
|
export const SET_PANELS_PREFERENCES = 'SET_PANELS_PREFERENCES';
|
|
11
|
-
const
|
|
12
|
-
function
|
|
13
|
-
switch (
|
|
14
|
-
case
|
|
15
|
-
return exercise1D;
|
|
16
|
-
case
|
|
17
|
-
return process1D;
|
|
9
|
+
const LOCAL_STORAGE_VERSION = 3;
|
|
10
|
+
function getPreferencesByWorkspace(workspace) {
|
|
11
|
+
switch (workspace) {
|
|
12
|
+
case NMRiumWorkspaces.EXERCISE_1D:
|
|
13
|
+
return workspaces.exercise1D;
|
|
14
|
+
case NMRiumWorkspaces.PROCESS_1D:
|
|
15
|
+
return workspaces.process1D;
|
|
18
16
|
default:
|
|
19
|
-
return basic;
|
|
17
|
+
return workspaces.basic;
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
20
|
export const preferencesInitialState = {
|
|
23
21
|
basePreferences: {},
|
|
24
|
-
display: basic,
|
|
22
|
+
display: workspaces.basic.display,
|
|
25
23
|
controllers: {
|
|
26
24
|
mws: { low: 2, high: 20 },
|
|
27
25
|
dimmedSpectraTransparency: 0.1,
|
|
@@ -39,7 +37,15 @@ export const preferencesInitialState = {
|
|
|
39
37
|
panels: {},
|
|
40
38
|
},
|
|
41
39
|
dispatch: null,
|
|
40
|
+
workspace: 'default',
|
|
42
41
|
};
|
|
42
|
+
function getTruthyObjectValues(data) {
|
|
43
|
+
return JSON.parse(JSON.stringify(data), (key, value) => {
|
|
44
|
+
if (value) {
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
43
49
|
function mapNucleus(draft) {
|
|
44
50
|
if (draft.formatting.nucleus && Array.isArray(draft.formatting.nucleus)) {
|
|
45
51
|
draft.formatting.nucleusByKey = draft.formatting.nucleus.reduce((acc, item) => {
|
|
@@ -50,48 +56,82 @@ function mapNucleus(draft) {
|
|
|
50
56
|
}
|
|
51
57
|
function handleInit(draft, action) {
|
|
52
58
|
const nmrLocalStorageVersion = getLocalStorage('nmr-local-storage-version', false);
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
let localData = getLocalStorage('nmr-general-settings');
|
|
60
|
+
// remove old nmr-local-storage-version key
|
|
61
|
+
if (nmrLocalStorageVersion && localData?.version) {
|
|
62
|
+
removeData('nmr-local-storage-version');
|
|
63
|
+
}
|
|
64
|
+
if (!localData?.version || localData?.version !== LOCAL_STORAGE_VERSION) {
|
|
55
65
|
removeData('nmr-general-settings');
|
|
56
|
-
storeData('nmr-local-storage-version', LOCAL_STORGAE_VERSION);
|
|
57
66
|
}
|
|
58
|
-
const localData = getLocalStorage('nmr-general-settings');
|
|
59
67
|
if (action.payload) {
|
|
60
|
-
const { dispatch,
|
|
61
|
-
draft.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
const { dispatch, workspace, ...resProps } = action.payload;
|
|
69
|
+
draft.workspace = workspace;
|
|
70
|
+
const workspacePreferences = getPreferencesByWorkspace(workspace);
|
|
71
|
+
if (!localData ||
|
|
72
|
+
!localData?.workspaces[workspace] ||
|
|
73
|
+
workspacePreferences.version !== localData?.workspaces[workspace]?.version) {
|
|
74
|
+
localData = localData || {};
|
|
75
|
+
localData = {
|
|
76
|
+
version: LOCAL_STORAGE_VERSION,
|
|
77
|
+
workspaces: {
|
|
78
|
+
...localData.workspaces,
|
|
79
|
+
[workspace]: {
|
|
80
|
+
...workspacePreferences,
|
|
81
|
+
controllers: draft.controllers,
|
|
82
|
+
formatting: draft.formatting,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
storeData('nmr-general-settings', JSON.stringify(localData));
|
|
87
|
+
}
|
|
88
|
+
draft.basePreferences = lodashMerge({}, workspacePreferences, resProps);
|
|
89
|
+
const hiddenModeFeatures = getTruthyObjectValues(draft.basePreferences.display);
|
|
90
|
+
let hiddenLocalStorageFeatures = {};
|
|
70
91
|
draft.dispatch = dispatch;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
92
|
+
const localStorageModePreferences = localData?.workspaces[workspace] || null;
|
|
93
|
+
if (localStorageModePreferences) {
|
|
94
|
+
Object.entries(localStorageModePreferences).forEach(([k, v]) => {
|
|
95
|
+
if (k === 'display') {
|
|
96
|
+
hiddenLocalStorageFeatures = getTruthyObjectValues(v);
|
|
97
|
+
}
|
|
98
|
+
else if (!['dispatch', 'basePreferences'].includes(k)) {
|
|
74
99
|
draft[k] = lodashMerge({}, resProps[k] ? resProps[k] : {}, v);
|
|
75
100
|
}
|
|
76
101
|
});
|
|
77
102
|
mapNucleus(draft);
|
|
78
103
|
}
|
|
104
|
+
draft.display = lodashMerge({}, getPreferencesByWorkspace(NMRiumWorkspaces.DEFAULT).display, hiddenModeFeatures, hiddenLocalStorageFeatures);
|
|
79
105
|
}
|
|
80
106
|
}
|
|
81
107
|
function handleSetPreferences(draft, action) {
|
|
82
108
|
if (action.payload) {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
109
|
+
const { controllers, formatting, display } = action.payload;
|
|
110
|
+
let localData = getLocalStorage('nmr-general-settings');
|
|
111
|
+
localData.workspaces = {
|
|
112
|
+
...localData.workspaces,
|
|
113
|
+
[draft.workspace]: {
|
|
114
|
+
...localData.workspaces[draft.workspace],
|
|
115
|
+
controllers,
|
|
116
|
+
formatting,
|
|
117
|
+
display,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
storeData('nmr-general-settings', JSON.stringify(localData));
|
|
121
|
+
draft.controllers = controllers;
|
|
122
|
+
draft.formatting = formatting;
|
|
123
|
+
draft.display.panels = display.panels;
|
|
124
|
+
draft.display.general.hideExperimentalFeatures =
|
|
125
|
+
display.general.hideExperimentalFeatures;
|
|
89
126
|
mapNucleus(draft);
|
|
90
127
|
}
|
|
91
128
|
}
|
|
92
129
|
function handleSetPanelsPreferences(draft, action) {
|
|
93
130
|
if (action.payload) {
|
|
94
131
|
const { key, value } = action.payload;
|
|
132
|
+
let localData = getLocalStorage('nmr-general-settings');
|
|
133
|
+
localData.workspaces[draft.workspace].formatting.panels[key] = value;
|
|
134
|
+
storeData('nmr-general-settings', JSON.stringify(localData));
|
|
95
135
|
draft.formatting.panels[key] = value;
|
|
96
136
|
}
|
|
97
137
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Toolbar } from 'analysis-ui-components';
|
|
3
3
|
import { SvgNmrBaselineCorrection, SvgNmrFourierTransform, SvgNmrIntegrate, SvgNmrMultipleAnalysis, SvgNmrPeakPicking, SvgNmrPhaseCorrection, SvgNmrRangePicking, SvgNmrZeroFilling, } from 'cheminfo-font';
|
|
4
|
-
import lodashGet from 'lodash/get';
|
|
5
4
|
import { useState, useEffect, useCallback, memo } from 'react';
|
|
6
5
|
import { FaSearchPlus, FaExpand, FaDiceFour } from 'react-icons/fa';
|
|
7
6
|
import * as Filters from '../../data/Filters';
|
|
8
7
|
import { useChartData } from '../context/ChartContext';
|
|
9
8
|
import { useDispatch } from '../context/DispatchContext';
|
|
10
|
-
import { usePreferences } from '../context/PreferencesContext';
|
|
11
9
|
import ToggleButton from '../elements/toggle/ToggleButton';
|
|
12
10
|
import ToggleButtonGroup from '../elements/toggle/ToggleButtonGroup';
|
|
11
|
+
import { useCheckToolsVisibility } from '../hooks/useCheckToolsVisibility';
|
|
13
12
|
import useDatumWithSpectraStatistics from '../hooks/useDatumWithSpectraStatistics';
|
|
14
13
|
import useToolsFunctions from '../hooks/useToolsFunctions';
|
|
15
14
|
import { DISPLAYER_MODE } from '../reducer/core/Constants';
|
|
@@ -17,7 +16,7 @@ import { APPLY_FFT_FILTER, SET_SELECTED_FILTER } from '../reducer/types/Types';
|
|
|
17
16
|
import { options } from './ToolTypes';
|
|
18
17
|
function FunctionToolBarInner({ defaultValue, activeSpectrum, info, datum, displayerMode, ftCounter, mode, }) {
|
|
19
18
|
const [option, setOption] = useState('');
|
|
20
|
-
const
|
|
19
|
+
const isButtonVisible = useCheckToolsVisibility();
|
|
21
20
|
const dispatch = useDispatch();
|
|
22
21
|
const { handleChangeOption, handleFullZoomOut } = useToolsFunctions();
|
|
23
22
|
const handleChange = useCallback((selectedOption) => {
|
|
@@ -34,35 +33,30 @@ function FunctionToolBarInner({ defaultValue, activeSpectrum, info, datum, displ
|
|
|
34
33
|
});
|
|
35
34
|
dispatch({ type: SET_SELECTED_FILTER, selectedFilter: null });
|
|
36
35
|
}, [dispatch]);
|
|
37
|
-
const isButtonVisible = useCallback((toolKey) => {
|
|
38
|
-
return !lodashGet(preferences, `display.toolBarButtons.${toolKey}`);
|
|
39
|
-
}, [preferences]);
|
|
40
|
-
const isPanelVisible = useCallback((panelKey) => {
|
|
41
|
-
return !lodashGet(preferences, `display.panels.${panelKey}`);
|
|
42
|
-
}, [preferences]);
|
|
43
36
|
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
37
|
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
38
|
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 &&
|
|
46
|
-
isButtonVisible('
|
|
47
|
-
isButtonVisible('
|
|
39
|
+
isButtonVisible('hideZonePickingTool') && (_jsx(ToggleButton, { value: options.zone2D.id, id: "zone2d", isVisible: activeSpectrum && !info?.isFid ? true : false, title: `${options.zone2D.label} ( Press r )`, children: _jsx(FaDiceFour, {}, void 0) }, options.zone2D.id)), displayerMode === DISPLAYER_MODE.DM_2D &&
|
|
40
|
+
isButtonVisible('hideSlicingTool') && (_jsx(ToggleButton, { value: options.slicingTool.id, isVisible: activeSpectrum && !info?.isFid ? true : false, id: "slic", title: `${options.slicingTool.label}`, children: _jsx("p", { children: "Slic" }, void 0) }, options.slicingTool.id)), displayerMode === DISPLAYER_MODE.DM_1D &&
|
|
41
|
+
isButtonVisible('hideAutoRangesTool') && (_jsx(ToggleButton, { value: options.rangesPicking.id, isVisible: activeSpectrum && !info?.isFid ? true : false, title: `${options.rangesPicking.label} ( Press r )`, id: "ranges-pick", children: _jsx(SvgNmrRangePicking, {}, void 0) }, options.rangesPicking.id)), displayerMode === DISPLAYER_MODE.DM_1D &&
|
|
48
42
|
isButtonVisible('hideMultipleSpectraAnalysisTool') &&
|
|
49
43
|
ftCounter > 1 &&
|
|
50
44
|
mode === 'RTL' && (_jsx(ToggleButton, { value: options.multipleSpectraAnalysis.id, id: "multipleSpectraAnalysis", title: options.multipleSpectraAnalysis.label, children: _jsx(SvgNmrMultipleAnalysis, {}, void 0) }, options.multipleSpectraAnalysis.id)), displayerMode === DISPLAYER_MODE.DM_1D &&
|
|
51
45
|
isButtonVisible('hideZeroFillingTool') && (_jsx(ToggleButton, { value: options.zeroFilling.id, isVisible: Filters.zeroFilling.isApplicable({ info }), id: "zeroFilling", title: options.zeroFilling.label, children: _jsx(SvgNmrZeroFilling, {}, void 0) }, options.zeroFilling.id)), displayerMode === DISPLAYER_MODE.DM_1D &&
|
|
52
|
-
isButtonVisible('hidePhaseCorrectionTool') && (_jsx(ToggleButton, { value: options.phaseCorrection.id, id: "phaseCorrection", title: options.phaseCorrection.label
|
|
46
|
+
isButtonVisible('hidePhaseCorrectionTool') && (_jsx(ToggleButton, { value: options.phaseCorrection.id, id: "phaseCorrection", title: `${options.phaseCorrection.label} ( Press a )`, isVisible: activeSpectrum &&
|
|
53
47
|
info &&
|
|
54
48
|
Filters.phaseCorrection.isApplicable({ info }) &&
|
|
55
49
|
datum.im
|
|
56
50
|
? true
|
|
57
51
|
: false, children: _jsx(SvgNmrPhaseCorrection, {}, void 0) }, options.phaseCorrection.id)), displayerMode === DISPLAYER_MODE.DM_1D &&
|
|
58
|
-
isButtonVisible('hideBaseLineCorrectionTool') && (_jsx(ToggleButton, { value: options.baseLineCorrection.id, id: "baseLineCorrection", title: options.baseLineCorrection.label
|
|
52
|
+
isButtonVisible('hideBaseLineCorrectionTool') && (_jsx(ToggleButton, { value: options.baseLineCorrection.id, id: "baseLineCorrection", title: `${options.baseLineCorrection.label} ( Press b )`, isVisible: activeSpectrum &&
|
|
59
53
|
info &&
|
|
60
54
|
Filters.baselineCorrection.isApplicable({ info })
|
|
61
55
|
? true
|
|
62
56
|
: false, children: _jsx(SvgNmrBaselineCorrection, {}, void 0) }, options.baseLineCorrection.id)), displayerMode === DISPLAYER_MODE.DM_1D &&
|
|
63
57
|
isButtonVisible('hideExclusionZonesTool') &&
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
!info?.isFid &&
|
|
59
|
+
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
60
|
isButtonVisible('hideFFTTool') &&
|
|
67
61
|
info &&
|
|
68
62
|
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));
|