nmrium 1.7.0 → 1.9.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/ranges/Atoms.d.ts.map +1 -1
- package/lib/component/1d/ranges/Atoms.js +24 -9
- package/lib/component/1d/ranges/Atoms.js.map +1 -1
- package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.d.ts +2 -1
- package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.d.ts.map +1 -1
- package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +32 -42
- package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js.map +1 -1
- package/lib/component/1d-2d/components/FloatMoleculeStructures/FloatMolecules.d.ts.map +1 -1
- package/lib/component/1d-2d/components/FloatMoleculeStructures/FloatMolecules.js.map +1 -1
- package/lib/component/2d/useTracesSpectra.d.ts.map +1 -1
- package/lib/component/2d/useTracesSpectra.js +2 -0
- package/lib/component/2d/useTracesSpectra.js.map +1 -1
- package/lib/component/2d/zones/SignalsGuideLines.js +1 -1
- package/lib/component/2d/zones/SignalsGuideLines.js.map +1 -1
- package/lib/component/EventsTrackers/KeysListenerTracker.d.ts.map +1 -1
- package/lib/component/EventsTrackers/KeysListenerTracker.js +6 -0
- package/lib/component/EventsTrackers/KeysListenerTracker.js.map +1 -1
- package/lib/component/hooks/useExport.js +1 -1
- package/lib/component/hooks/useExport.js.map +1 -1
- package/lib/component/loader/useLoadFiles.d.ts.map +1 -1
- package/lib/component/loader/useLoadFiles.js +17 -7
- package/lib/component/loader/useLoadFiles.js.map +1 -1
- package/lib/component/main/NMRiumStateProvider.d.ts.map +1 -1
- package/lib/component/main/NMRiumStateProvider.js +2 -3
- package/lib/component/main/NMRiumStateProvider.js.map +1 -1
- package/lib/component/modal/LoadJCAMPModal.js +7 -2
- package/lib/component/modal/LoadJCAMPModal.js.map +1 -1
- package/lib/component/modal/MoleculeStructureEditorModal.d.ts.map +1 -1
- package/lib/component/modal/MoleculeStructureEditorModal.js +7 -3
- package/lib/component/modal/MoleculeStructureEditorModal.js.map +1 -1
- package/lib/component/modal/MultipletAnalysisModal.js +1 -1
- package/lib/component/modal/SaveAsModal.d.ts.map +1 -1
- package/lib/component/modal/SaveAsModal.js +6 -2
- package/lib/component/modal/SaveAsModal.js.map +1 -1
- package/lib/component/modal/setting/settings-tabs/ToolsTabContent.d.ts.map +1 -1
- package/lib/component/modal/setting/settings-tabs/ToolsTabContent.js +17 -1
- package/lib/component/modal/setting/settings-tabs/ToolsTabContent.js.map +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculeOptionsPanel.d.ts +6 -0
- package/lib/component/panels/MoleculesPanel/MoleculeOptionsPanel.d.ts.map +1 -0
- package/lib/component/panels/MoleculesPanel/MoleculeOptionsPanel.js +87 -0
- package/lib/component/panels/MoleculesPanel/MoleculeOptionsPanel.js.map +1 -0
- package/lib/component/panels/MoleculesPanel/MoleculePanel.d.ts.map +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanel.js +18 -26
- package/lib/component/panels/MoleculesPanel/MoleculePanel.js.map +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts.map +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +36 -31
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js.map +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculeStructure.d.ts +13 -0
- package/lib/component/panels/MoleculesPanel/MoleculeStructure.d.ts.map +1 -0
- package/lib/component/panels/MoleculesPanel/MoleculeStructure.js +66 -0
- package/lib/component/panels/MoleculesPanel/MoleculeStructure.js.map +1 -0
- package/lib/component/panels/MoleculesPanel/{useAtomAssignment.d.ts → hooks/useAtomAssignment.d.ts} +1 -1
- package/lib/component/panels/MoleculesPanel/hooks/useAtomAssignment.d.ts.map +1 -0
- package/lib/component/panels/MoleculesPanel/{useAtomAssignment.js → hooks/useAtomAssignment.js} +32 -16
- package/lib/component/panels/MoleculesPanel/hooks/useAtomAssignment.js.map +1 -0
- package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.d.ts +12 -0
- package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.d.ts.map +1 -0
- package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.js +58 -0
- package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.js.map +1 -0
- package/lib/component/panels/MoleculesPanel/utilities/AtomData.d.ts +5 -0
- package/lib/component/panels/MoleculesPanel/utilities/AtomData.d.ts.map +1 -0
- package/lib/component/panels/MoleculesPanel/utilities/AtomData.js +2 -0
- package/lib/component/panels/MoleculesPanel/utilities/AtomData.js.map +1 -0
- package/lib/component/panels/MoleculesPanel/utilities/extractFromAtom.d.ts +16 -0
- package/lib/component/panels/MoleculesPanel/utilities/extractFromAtom.d.ts.map +1 -0
- package/lib/component/panels/MoleculesPanel/utilities/extractFromAtom.js +47 -0
- package/lib/component/panels/MoleculesPanel/utilities/extractFromAtom.js.map +1 -0
- package/lib/component/panels/MoleculesPanel/utilities/getAssignIds.d.ts +18 -0
- package/lib/component/panels/MoleculesPanel/utilities/getAssignIds.d.ts.map +1 -0
- package/lib/component/panels/MoleculesPanel/utilities/getAssignIds.js +31 -0
- package/lib/component/panels/MoleculesPanel/utilities/getAssignIds.js.map +1 -0
- package/lib/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.d.ts +3 -0
- package/lib/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.d.ts.map +1 -0
- package/lib/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.js +12 -0
- package/lib/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.js.map +1 -0
- package/lib/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.d.ts +4 -0
- package/lib/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.d.ts.map +1 -0
- package/lib/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.js +25 -0
- package/lib/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.js.map +1 -0
- package/lib/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.d.ts +6 -0
- package/lib/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.d.ts.map +1 -0
- package/lib/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.js +18 -0
- package/lib/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.js.map +1 -0
- package/lib/component/panels/databasePanel/DatabaseInfo.d.ts +5 -0
- package/lib/component/panels/databasePanel/DatabaseInfo.d.ts.map +1 -0
- package/lib/component/panels/databasePanel/DatabaseInfo.js +29 -0
- package/lib/component/panels/databasePanel/DatabaseInfo.js.map +1 -0
- package/lib/component/panels/databasePanel/DatabaseTable.d.ts.map +1 -1
- package/lib/component/panels/databasePanel/DatabaseTable.js +21 -3
- package/lib/component/panels/databasePanel/DatabaseTable.js.map +1 -1
- package/lib/component/panels/hooks/useMoleculeAnnotationCore.d.ts +9 -0
- package/lib/component/panels/hooks/useMoleculeAnnotationCore.d.ts.map +1 -0
- package/lib/component/panels/hooks/useMoleculeAnnotationCore.js +27 -0
- package/lib/component/panels/hooks/useMoleculeAnnotationCore.js.map +1 -0
- package/lib/component/panels/informationPanel/InformationEditionModal.js +1 -1
- package/lib/component/panels/informationPanel/InformationEditionModal.js.map +1 -1
- package/lib/component/reducer/IgnoreActions.d.ts.map +1 -1
- package/lib/component/reducer/IgnoreActions.js +2 -1
- package/lib/component/reducer/IgnoreActions.js.map +1 -1
- package/lib/component/reducer/Reducer.d.ts +11 -5
- package/lib/component/reducer/Reducer.d.ts.map +1 -1
- package/lib/component/reducer/Reducer.js +8 -3
- package/lib/component/reducer/Reducer.js.map +1 -1
- package/lib/component/reducer/actions/DatabaseActions.d.ts.map +1 -1
- package/lib/component/reducer/actions/DatabaseActions.js +4 -2
- package/lib/component/reducer/actions/DatabaseActions.js.map +1 -1
- package/lib/component/reducer/actions/LoadAction.d.ts +7 -4
- package/lib/component/reducer/actions/LoadAction.d.ts.map +1 -1
- package/lib/component/reducer/actions/LoadAction.js +35 -26
- package/lib/component/reducer/actions/LoadAction.js.map +1 -1
- package/lib/component/reducer/actions/MoleculeActions.d.ts +20 -5
- package/lib/component/reducer/actions/MoleculeActions.d.ts.map +1 -1
- package/lib/component/reducer/actions/MoleculeActions.js +42 -28
- package/lib/component/reducer/actions/MoleculeActions.js.map +1 -1
- package/lib/component/reducer/actions/RangesActions.d.ts +10 -4
- package/lib/component/reducer/actions/RangesActions.d.ts.map +1 -1
- package/lib/component/reducer/actions/RangesActions.js +24 -3
- package/lib/component/reducer/actions/RangesActions.js.map +1 -1
- package/lib/component/reducer/actions/ZonesActions.d.ts +1 -1
- package/lib/component/reducer/actions/ZonesActions.d.ts.map +1 -1
- package/lib/component/reducer/preferences/actions/changeDefaultMoleculeSettings.d.ts +4 -0
- package/lib/component/reducer/preferences/actions/changeDefaultMoleculeSettings.d.ts.map +1 -0
- package/lib/component/reducer/preferences/actions/changeDefaultMoleculeSettings.js +7 -0
- package/lib/component/reducer/preferences/actions/changeDefaultMoleculeSettings.js.map +1 -0
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +1 -1
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js.map +1 -1
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -2
- package/lib/component/reducer/preferences/preferencesReducer.d.ts.map +1 -1
- package/lib/component/reducer/preferences/preferencesReducer.js +3 -0
- package/lib/component/reducer/preferences/preferencesReducer.js.map +1 -1
- package/lib/component/toolbar/ToolBar.d.ts.map +1 -1
- package/lib/component/toolbar/ToolBar.js +5 -1
- package/lib/component/toolbar/ToolBar.js.map +1 -1
- package/lib/component/toolbar/ToolTypes.d.ts.map +1 -1
- package/lib/component/toolbar/ToolTypes.js +2 -1
- package/lib/component/toolbar/ToolTypes.js.map +1 -1
- package/lib/component/utility/filterDatabaseInfoEntry.d.ts +3 -0
- package/lib/component/utility/filterDatabaseInfoEntry.d.ts.map +1 -0
- package/lib/component/utility/filterDatabaseInfoEntry.js +9 -0
- package/lib/component/utility/filterDatabaseInfoEntry.js.map +1 -0
- package/lib/component/workspaces/assignment.d.ts.map +1 -1
- package/lib/component/workspaces/assignment.js +7 -0
- package/lib/component/workspaces/assignment.js.map +1 -1
- package/lib/component/workspaces/basic.d.ts.map +1 -1
- package/lib/component/workspaces/basic.js +5 -0
- package/lib/component/workspaces/basic.js.map +1 -1
- package/lib/component/workspaces/embedded.d.ts.map +1 -1
- package/lib/component/workspaces/embedded.js +5 -0
- package/lib/component/workspaces/embedded.js.map +1 -1
- package/lib/component/workspaces/exercise.d.ts.map +1 -1
- package/lib/component/workspaces/exercise.js +5 -0
- package/lib/component/workspaces/exercise.js.map +1 -1
- package/lib/component/workspaces/prediction.d.ts.map +1 -1
- package/lib/component/workspaces/prediction.js +6 -1
- package/lib/component/workspaces/prediction.js.map +1 -1
- package/lib/component/workspaces/process1D.d.ts.map +1 -1
- package/lib/component/workspaces/process1D.js +6 -0
- package/lib/component/workspaces/process1D.js.map +1 -1
- package/lib/component/workspaces/simulation.js +1 -1
- package/lib/component/workspaces/simulation.js.map +1 -1
- package/lib/component/workspaces/workspaceDefaultProperties.d.ts.map +1 -1
- package/lib/component/workspaces/workspaceDefaultProperties.js +19 -1
- package/lib/component/workspaces/workspaceDefaultProperties.js.map +1 -1
- package/lib/data/SpectraManager.d.ts +1 -1
- package/lib/data/SpectraManager.d.ts.map +1 -1
- package/lib/data/SpectraManager.js.map +1 -1
- package/lib/data/data1d/Spectrum1D/initiateDatum1D.d.ts +0 -1
- package/lib/data/data1d/Spectrum1D/initiateDatum1D.d.ts.map +1 -1
- package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +17 -16
- package/lib/data/data1d/Spectrum1D/initiateDatum1D.js.map +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.d.ts.map +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js +2 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js.map +1 -1
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.d.ts +0 -1
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.d.ts.map +1 -1
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +7 -6
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js.map +1 -1
- package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts.map +1 -1
- package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts.map +1 -1
- package/lib/data/molecules/Molecule.d.ts +1 -17
- package/lib/data/molecules/Molecule.d.ts.map +1 -1
- package/lib/data/molecules/Molecule.js +3 -7
- package/lib/data/molecules/Molecule.js.map +1 -1
- package/lib/data/molecules/MoleculeManager.d.ts +3 -2
- package/lib/data/molecules/MoleculeManager.d.ts.map +1 -1
- package/lib/data/molecules/MoleculeManager.js +31 -7
- package/lib/data/molecules/MoleculeManager.js.map +1 -1
- package/lib/utils/clipboard/clipboardHooks.js +4 -4
- package/lib/utils/clipboard/clipboardHooks.js.map +1 -1
- package/lib/versionInfo.js +1 -1
- package/package.json +30 -29
- package/src/component/1d/ranges/Atoms.tsx +36 -13
- package/src/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.tsx +38 -79
- package/src/component/1d-2d/components/FloatMoleculeStructures/FloatMolecules.tsx +5 -2
- package/src/component/2d/useTracesSpectra.ts +2 -0
- package/src/component/2d/zones/SignalsGuideLines.tsx +1 -1
- package/src/component/EventsTrackers/KeysListenerTracker.tsx +6 -0
- package/src/component/hooks/useExport.tsx +1 -1
- package/src/component/loader/useLoadFiles.ts +19 -7
- package/src/component/main/NMRiumStateProvider.tsx +2 -3
- package/src/component/modal/LoadJCAMPModal.tsx +10 -4
- package/src/component/modal/MoleculeStructureEditorModal.tsx +10 -3
- package/src/component/modal/MultipletAnalysisModal.tsx +1 -1
- package/src/component/modal/SaveAsModal.tsx +8 -2
- package/src/component/modal/setting/settings-tabs/ToolsTabContent.tsx +17 -1
- package/src/component/panels/MoleculesPanel/MoleculeOptionsPanel.tsx +160 -0
- package/src/component/panels/MoleculesPanel/MoleculePanel.tsx +77 -101
- package/src/component/panels/MoleculesPanel/MoleculePanelHeader.tsx +63 -42
- package/src/component/panels/MoleculesPanel/MoleculeStructure.tsx +117 -0
- package/src/component/panels/MoleculesPanel/{useAtomAssignment.tsx → hooks/useAtomAssignment.tsx} +47 -25
- package/src/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.ts +74 -0
- package/src/component/panels/MoleculesPanel/utilities/AtomData.ts +4 -0
- package/src/component/panels/MoleculesPanel/utilities/extractFromAtom.ts +63 -0
- package/src/component/panels/MoleculesPanel/utilities/getAssignIds.ts +59 -0
- package/src/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.ts +12 -0
- package/src/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.ts +36 -0
- package/src/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.ts +20 -0
- package/src/component/panels/databasePanel/DatabaseInfo.tsx +43 -0
- package/src/component/panels/databasePanel/DatabaseTable.tsx +33 -1
- package/src/component/panels/hooks/useMoleculeAnnotationCore.ts +36 -0
- package/src/component/panels/informationPanel/InformationEditionModal.tsx +2 -0
- package/src/component/reducer/IgnoreActions.ts +2 -1
- package/src/component/reducer/Reducer.ts +21 -8
- package/src/component/reducer/actions/DatabaseActions.ts +4 -2
- package/src/component/reducer/actions/LoadAction.ts +51 -38
- package/src/component/reducer/actions/MoleculeActions.ts +85 -37
- package/src/component/reducer/actions/RangesActions.ts +50 -5
- package/src/component/reducer/actions/ZonesActions.ts +1 -1
- package/src/component/reducer/preferences/actions/changeDefaultMoleculeSettings.ts +16 -0
- package/src/component/reducer/preferences/panelsPreferencesDefaultValues.ts +1 -1
- package/src/component/reducer/preferences/preferencesReducer.ts +11 -1
- package/src/component/toolbar/ToolBar.tsx +6 -1
- package/src/component/toolbar/ToolTypes.ts +2 -1
- package/src/component/utility/filterDatabaseInfoEntry.ts +10 -0
- package/src/component/workspaces/assignment.ts +7 -0
- package/src/component/workspaces/basic.ts +5 -0
- package/src/component/workspaces/embedded.ts +5 -0
- package/src/component/workspaces/exercise.ts +5 -0
- package/src/component/workspaces/prediction.ts +6 -1
- package/src/component/workspaces/process1D.ts +6 -0
- package/src/component/workspaces/simulation.ts +1 -1
- package/src/component/workspaces/workspaceDefaultProperties.ts +19 -1
- package/src/data/SpectraManager.ts +1 -7
- package/src/data/data1d/Spectrum1D/initiateDatum1D.ts +17 -19
- package/src/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.ts +2 -1
- package/src/data/data2d/Spectrum2D/initiateDatum2D.ts +7 -10
- package/src/data/molecules/Molecule.ts +5 -25
- package/src/data/molecules/MoleculeManager.ts +40 -8
- package/src/index.tsx +0 -3
- package/src/utils/clipboard/clipboardHooks.ts +6 -6
- package/src/versionInfo.ts +1 -1
- package/lib/component/panels/MoleculesPanel/Utilities.d.ts +0 -43
- package/lib/component/panels/MoleculesPanel/Utilities.d.ts.map +0 -1
- package/lib/component/panels/MoleculesPanel/Utilities.js +0 -129
- package/lib/component/panels/MoleculesPanel/Utilities.js.map +0 -1
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts.map +0 -1
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js.map +0 -1
- package/src/component/panels/MoleculesPanel/Utilities.ts +0 -188
|
@@ -29,8 +29,9 @@ const ignoreActions = new Set<Partial<Action['type']>>([
|
|
|
29
29
|
'TOGGLE_REAL_IMAGINARY_VISIBILITY',
|
|
30
30
|
'FLOAT_MOLECULE_OVER_SPECTRUM',
|
|
31
31
|
'TOGGLE_SPECTRA_LEGEND',
|
|
32
|
-
'
|
|
32
|
+
'CHANGE_MOLECULE_ANNOTATION',
|
|
33
33
|
'SET_2D_LEVEL',
|
|
34
|
+
'TOGGLE_MOLECULE_LABEL',
|
|
34
35
|
]);
|
|
35
36
|
|
|
36
37
|
function checkActionType(type: Action['type']): boolean {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BaselineCorrectionZone } from '@zakodium/nmr-types';
|
|
2
2
|
import type { Spectrum, ViewState } from '@zakodium/nmrium-core';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Source } from 'file-collection';
|
|
4
|
+
import { FileCollection } from 'file-collection';
|
|
4
5
|
import type { Draft } from 'immer';
|
|
5
6
|
import { original, produce } from 'immer';
|
|
6
7
|
import type { CorrelationData } from 'nmr-correlation';
|
|
@@ -114,7 +115,7 @@ export function getDefaultViewState(): ViewState {
|
|
|
114
115
|
export const getInitialState = (): State => ({
|
|
115
116
|
actionType: 'INITIALIZE_NMRIUM',
|
|
116
117
|
sources: {},
|
|
117
|
-
|
|
118
|
+
aggregator: new FileCollection(),
|
|
118
119
|
data: [],
|
|
119
120
|
tempData: null,
|
|
120
121
|
xDomain: [],
|
|
@@ -192,15 +193,20 @@ export interface State {
|
|
|
192
193
|
|
|
193
194
|
/**
|
|
194
195
|
* web source of data
|
|
195
|
-
* Record key is identifier of the source (stored in spectra)
|
|
196
|
+
* Record key is an identifier of the source (stored in spectra)
|
|
197
|
+
*
|
|
198
|
+
* Is needed until we remove the support of the old nmrium format
|
|
196
199
|
*/
|
|
197
200
|
sources: Record<string, Source>;
|
|
198
201
|
|
|
199
202
|
/**
|
|
200
|
-
*
|
|
201
|
-
*
|
|
203
|
+
* Aggregation of file collections used to load the data
|
|
204
|
+
* - external data sources (web-source, import jdx from url, ...)
|
|
205
|
+
* - multiples files open / drag and drop
|
|
206
|
+
*
|
|
207
|
+
* Each of them is separated in an uuid folder
|
|
202
208
|
*/
|
|
203
|
-
|
|
209
|
+
aggregator: FileCollection;
|
|
204
210
|
|
|
205
211
|
/**
|
|
206
212
|
* spectra list (1d and 2d)
|
|
@@ -669,10 +675,12 @@ function innerSpectrumReducer(draft: Draft<State>, action: Action) {
|
|
|
669
675
|
return MoleculeActions.handlePredictSpectraFromMolecule(draft, action);
|
|
670
676
|
case 'FLOAT_MOLECULE_OVER_SPECTRUM':
|
|
671
677
|
return MoleculeActions.handleFloatMoleculeOverSpectrum(draft, action);
|
|
672
|
-
case '
|
|
673
|
-
return MoleculeActions.
|
|
678
|
+
case 'CHANGE_MOLECULE_ANNOTATION':
|
|
679
|
+
return MoleculeActions.handleChangeMoleculeAnnotation(draft, action);
|
|
674
680
|
case 'CHANGE_FLOAT_MOLECULE_POSITION':
|
|
675
681
|
return MoleculeActions.handleChangeFloatMoleculePosition(draft, action);
|
|
682
|
+
case 'TOGGLE_MOLECULE_LABEL':
|
|
683
|
+
return MoleculeActions.handleToggleMoleculeLabel(draft, action);
|
|
676
684
|
|
|
677
685
|
case 'SET_CORRELATIONS_MF':
|
|
678
686
|
return CorrelationsActions.handleSetMF(draft, action);
|
|
@@ -730,6 +738,11 @@ function innerSpectrumReducer(draft: Draft<State>, action: Action) {
|
|
|
730
738
|
draft,
|
|
731
739
|
action,
|
|
732
740
|
);
|
|
741
|
+
case 'CHANGE_ASSIGNMENT_LABEL_BY_DIAIDS':
|
|
742
|
+
return RangesActions.handleChangeRangesAssignmentLabelsByDiaIds(
|
|
743
|
+
draft,
|
|
744
|
+
action,
|
|
745
|
+
);
|
|
733
746
|
|
|
734
747
|
case 'SET_KEY_PREFERENCES':
|
|
735
748
|
return PreferencesActions.handleSetKeyPreferences(draft, action);
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
resurrectSpectrumFromRanges,
|
|
13
13
|
resurrectSpectrumFromSignals,
|
|
14
14
|
} from '../../../data/data1d/Spectrum1D/ranges/resurrectSpectrum.js';
|
|
15
|
+
import { filterDatabaseInfoEntry } from '../../utility/filterDatabaseInfoEntry.ts';
|
|
15
16
|
import type { State } from '../Reducer.js';
|
|
16
17
|
import { setZoom } from '../helper/Zoom1DManager.js';
|
|
17
18
|
import zoomHistoryManager from '../helper/ZoomHistoryManager.js';
|
|
@@ -59,7 +60,6 @@ function handleResurrectSpectrum(
|
|
|
59
60
|
ranges,
|
|
60
61
|
signals,
|
|
61
62
|
solvent,
|
|
62
|
-
meta = {},
|
|
63
63
|
names = [],
|
|
64
64
|
id: spectrumID,
|
|
65
65
|
} = databaseEntry;
|
|
@@ -68,6 +68,7 @@ function handleResurrectSpectrum(
|
|
|
68
68
|
|
|
69
69
|
if (source === 'jcamp') {
|
|
70
70
|
const { spectrum } = action.payload;
|
|
71
|
+
|
|
71
72
|
resurrectedSpectrum = {
|
|
72
73
|
...spectrum,
|
|
73
74
|
id: spectrumID,
|
|
@@ -115,7 +116,8 @@ function handleResurrectSpectrum(
|
|
|
115
116
|
|
|
116
117
|
if (!resurrectedSpectrum) return;
|
|
117
118
|
|
|
118
|
-
|
|
119
|
+
const filterDatabaseEntryInfo = filterDatabaseInfoEntry(databaseEntry);
|
|
120
|
+
resurrectedSpectrum.customInfo = filterDatabaseEntryInfo;
|
|
119
121
|
|
|
120
122
|
draft.data.push(resurrectedSpectrum);
|
|
121
123
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
MoleculeView,
|
|
2
3
|
NmriumState,
|
|
3
4
|
SpectraColors,
|
|
4
5
|
Spectrum,
|
|
5
6
|
ViewState,
|
|
6
7
|
} from '@zakodium/nmrium-core';
|
|
7
|
-
import
|
|
8
|
+
import { FileCollection } from 'file-collection';
|
|
8
9
|
import type { Draft } from 'immer';
|
|
9
10
|
import { produce } from 'immer';
|
|
10
11
|
import lodashMerge from 'lodash/merge.js';
|
|
@@ -24,6 +25,7 @@ import type { State } from '../Reducer.js';
|
|
|
24
25
|
import { getDefaultViewState, getInitialState } from '../Reducer.js';
|
|
25
26
|
import type { ActionType } from '../types/ActionType.js';
|
|
26
27
|
|
|
28
|
+
import { initMoleculeViewProperties } from './MoleculeActions.ts';
|
|
27
29
|
import { changeSpectrumVerticalAlignment } from './PreferencesActions.js';
|
|
28
30
|
import { setSpectraMetaInfo } from './SpectraActions.js';
|
|
29
31
|
import { setActiveTab } from './ToolsActions.js';
|
|
@@ -31,15 +33,18 @@ import { setActiveTab } from './ToolsActions.js';
|
|
|
31
33
|
//TODO use viewState type instead of any { view?: ViewState }
|
|
32
34
|
interface InitiateProps {
|
|
33
35
|
nmriumState: Partial<NmriumState>;
|
|
34
|
-
|
|
36
|
+
aggregator: FileCollection;
|
|
35
37
|
}
|
|
36
|
-
interface InputProps extends InitiateProps {
|
|
38
|
+
interface InputProps extends Omit<InitiateProps, 'aggregator'> {
|
|
37
39
|
containsNmrium?: boolean;
|
|
38
40
|
usedColors?: UsedColors;
|
|
39
41
|
parseMetaFileResult?: ParseResult<any> | null;
|
|
40
42
|
resetSourceObject?: boolean;
|
|
41
43
|
spectraColors?: SpectraColors;
|
|
42
44
|
fileCollection?: FileCollection;
|
|
45
|
+
selectorRoot?: string;
|
|
46
|
+
aggregator?: FileCollection;
|
|
47
|
+
defaultMoleculeSettings?: MoleculeView;
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
type SetIsLoadingAction = ActionType<
|
|
@@ -92,6 +97,12 @@ function setCorrelation(draft: Draft<State>, correlations: CorrelationData) {
|
|
|
92
97
|
}
|
|
93
98
|
}
|
|
94
99
|
|
|
100
|
+
function isDataSourceDropFiles(
|
|
101
|
+
input: InputProps | InitiateProps,
|
|
102
|
+
): input is InputProps {
|
|
103
|
+
return 'containsNmrium' in input;
|
|
104
|
+
}
|
|
105
|
+
|
|
95
106
|
function setData(draft: Draft<State>, input: InputProps | InitiateProps) {
|
|
96
107
|
const { data, view } = input.nmriumState || {
|
|
97
108
|
data: { spectra: [], molecules: [], correlations: {} },
|
|
@@ -118,6 +129,7 @@ function setData(draft: Draft<State>, input: InputProps | InitiateProps) {
|
|
|
118
129
|
|
|
119
130
|
if (view) {
|
|
120
131
|
const defaultViewState = getDefaultViewState();
|
|
132
|
+
|
|
121
133
|
draft.view = lodashMerge(defaultViewState, view);
|
|
122
134
|
}
|
|
123
135
|
|
|
@@ -140,31 +152,46 @@ function setData(draft: Draft<State>, input: InputProps | InitiateProps) {
|
|
|
140
152
|
}
|
|
141
153
|
}
|
|
142
154
|
|
|
143
|
-
|
|
155
|
+
if (input.aggregator) {
|
|
156
|
+
if ('forceInitialize' in input && input.forceInitialize) {
|
|
157
|
+
draft.aggregator = input.aggregator;
|
|
158
|
+
} else {
|
|
159
|
+
draft.aggregator = FileCollection.fromCollection(draft.aggregator);
|
|
160
|
+
draft.aggregator.appendFileCollection(input.aggregator, '');
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (
|
|
165
|
+
'fileCollection' in input &&
|
|
166
|
+
input.fileCollection &&
|
|
167
|
+
'selectorRoot' in input &&
|
|
168
|
+
input.selectorRoot
|
|
169
|
+
) {
|
|
170
|
+
draft.aggregator = FileCollection.fromCollection(draft.aggregator);
|
|
171
|
+
draft.aggregator.appendFileCollection(
|
|
172
|
+
input.fileCollection,
|
|
173
|
+
input.selectorRoot,
|
|
174
|
+
);
|
|
175
|
+
}
|
|
144
176
|
|
|
145
|
-
const
|
|
146
|
-
'fileCollection' in input
|
|
147
|
-
? sources?.at(-1)?.id || crypto.randomUUID()
|
|
148
|
-
: undefined;
|
|
149
|
-
const fileCollection =
|
|
150
|
-
'fileCollection' in input ? input.fileCollection : undefined;
|
|
177
|
+
const newMolecules = MoleculeManager.fromJSON(molecules, draft.molecules);
|
|
151
178
|
|
|
152
|
-
draft.molecules = draft.molecules.concat(
|
|
153
|
-
|
|
154
|
-
)
|
|
179
|
+
draft.molecules = draft.molecules.concat(newMolecules);
|
|
180
|
+
|
|
181
|
+
if (isDataSourceDropFiles(input) && !input?.containsNmrium) {
|
|
182
|
+
const { defaultMoleculeSettings } = input;
|
|
183
|
+
for (const { id } of newMolecules) {
|
|
184
|
+
initMoleculeViewProperties(draft, { id, defaultMoleculeSettings });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
155
187
|
|
|
156
188
|
draft.data = draft.data.concat(
|
|
157
189
|
initSpectra(spectra, {
|
|
158
190
|
usedColors: draft.usedColors,
|
|
159
191
|
molecules: draft.molecules,
|
|
160
192
|
spectraColors,
|
|
161
|
-
fileCollectionId,
|
|
162
193
|
}),
|
|
163
194
|
);
|
|
164
|
-
if (fileCollection && fileCollectionId) {
|
|
165
|
-
draft.fileCollections ??= {};
|
|
166
|
-
draft.fileCollections[fileCollectionId] = fileCollection;
|
|
167
|
-
}
|
|
168
195
|
setCorrelation(draft, correlations);
|
|
169
196
|
|
|
170
197
|
if (parseMetaFileResult) {
|
|
@@ -183,11 +210,10 @@ function initSpectra(
|
|
|
183
210
|
usedColors: UsedColors;
|
|
184
211
|
molecules: StateMoleculeExtended[];
|
|
185
212
|
spectraColors: SpectraColors;
|
|
186
|
-
fileCollectionId: string | undefined;
|
|
187
213
|
},
|
|
188
214
|
) {
|
|
189
215
|
const spectra: any = [];
|
|
190
|
-
const { usedColors, molecules, spectraColors
|
|
216
|
+
const { usedColors, molecules, spectraColors } = options;
|
|
191
217
|
for (const spectrum of inputSpectra) {
|
|
192
218
|
const { info } = spectrum;
|
|
193
219
|
if (info.dimension === 1) {
|
|
@@ -196,14 +222,13 @@ function initSpectra(
|
|
|
196
222
|
usedColors,
|
|
197
223
|
molecules,
|
|
198
224
|
colors: spectraColors.oneDimension,
|
|
199
|
-
fileCollectionId,
|
|
200
225
|
}),
|
|
201
226
|
);
|
|
202
227
|
} else if (info.dimension === 2) {
|
|
203
228
|
spectra.push(
|
|
204
229
|
initiateDatum2D(
|
|
205
230
|
{ ...spectrum },
|
|
206
|
-
{ usedColors, colors: spectraColors.twoDimensions
|
|
231
|
+
{ usedColors, colors: spectraColors.twoDimensions },
|
|
207
232
|
),
|
|
208
233
|
);
|
|
209
234
|
}
|
|
@@ -228,21 +253,6 @@ function setPreferences(draft: Draft<State>, data: ViewState) {
|
|
|
228
253
|
}
|
|
229
254
|
}
|
|
230
255
|
|
|
231
|
-
function updateFileCollections(
|
|
232
|
-
draft: Draft<State>,
|
|
233
|
-
payload: Pick<InitiateProps, 'fileCollections'>,
|
|
234
|
-
) {
|
|
235
|
-
const fileCollections = payload.fileCollections;
|
|
236
|
-
if (!fileCollections) return;
|
|
237
|
-
|
|
238
|
-
if (fileCollections.size > 0) {
|
|
239
|
-
draft.fileCollections ??= {};
|
|
240
|
-
}
|
|
241
|
-
for (const [id, fc] of fileCollections) {
|
|
242
|
-
draft.fileCollections[id] = fc;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
256
|
function initData(
|
|
247
257
|
draft: Draft<State>,
|
|
248
258
|
action: LoadDropFilesAction | InitiateAction,
|
|
@@ -272,7 +282,10 @@ function initData(
|
|
|
272
282
|
initialDraft.actionType = action.type;
|
|
273
283
|
});
|
|
274
284
|
} else {
|
|
275
|
-
|
|
285
|
+
if (action.payload.aggregator) {
|
|
286
|
+
draft.aggregator = FileCollection.fromCollection(draft.aggregator);
|
|
287
|
+
draft.aggregator.appendFileCollection(action.payload.aggregator, '');
|
|
288
|
+
}
|
|
276
289
|
if (view) {
|
|
277
290
|
const defaultViewState = getDefaultViewState();
|
|
278
291
|
draft.view = lodashMerge(defaultViewState, view);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StateMolecule } from '@zakodium/nmrium-core';
|
|
1
|
+
import type { MoleculeView, StateMolecule } from '@zakodium/nmrium-core';
|
|
2
2
|
import type { Logger } from 'cheminfo-types';
|
|
3
3
|
import type { FifoLogger } from 'fifo-logger';
|
|
4
4
|
import type { Draft } from 'immer';
|
|
@@ -31,11 +31,15 @@ interface AddMoleculeProps {
|
|
|
31
31
|
molfile: string;
|
|
32
32
|
id?: string;
|
|
33
33
|
floatMoleculeOnSave?: boolean;
|
|
34
|
+
defaultMoleculeSettings?: MoleculeView;
|
|
34
35
|
}
|
|
35
36
|
type AddMoleculeAction = ActionType<'ADD_MOLECULE', AddMoleculeProps>;
|
|
36
37
|
type AddMoleculesAction = ActionType<
|
|
37
38
|
'ADD_MOLECULES',
|
|
38
|
-
{
|
|
39
|
+
{
|
|
40
|
+
molecules: StateMolecule[];
|
|
41
|
+
defaultMoleculeSettings?: MoleculeView;
|
|
42
|
+
}
|
|
39
43
|
>;
|
|
40
44
|
type SetMoleculeAction = ActionType<
|
|
41
45
|
'SET_MOLECULE',
|
|
@@ -56,9 +60,23 @@ type PredictSpectraFromMoleculeAction = ActionType<
|
|
|
56
60
|
}
|
|
57
61
|
>;
|
|
58
62
|
type ToggleMoleculeViewObjectAction = ActionType<
|
|
59
|
-
'FLOAT_MOLECULE_OVER_SPECTRUM'
|
|
63
|
+
'FLOAT_MOLECULE_OVER_SPECTRUM',
|
|
60
64
|
{ id: string }
|
|
61
65
|
>;
|
|
66
|
+
type ToggleMoleculeLabelAction = ActionType<
|
|
67
|
+
'TOGGLE_MOLECULE_LABEL',
|
|
68
|
+
{ id: string }
|
|
69
|
+
>;
|
|
70
|
+
|
|
71
|
+
interface ChangeMoleculeAnnotationOptions
|
|
72
|
+
extends Pick<MoleculeView, 'atomAnnotation'> {
|
|
73
|
+
id: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
type ChangeMoleculeAnnotationAction = ActionType<
|
|
77
|
+
'CHANGE_MOLECULE_ANNOTATION',
|
|
78
|
+
ChangeMoleculeAnnotationOptions
|
|
79
|
+
>;
|
|
62
80
|
type ChangeFloatMoleculePositionAction = ActionType<
|
|
63
81
|
'CHANGE_FLOAT_MOLECULE_POSITION',
|
|
64
82
|
{ id: string; bounding: MoleculeBoundingRect }
|
|
@@ -76,10 +94,12 @@ export type MoleculeActions =
|
|
|
76
94
|
| PredictSpectraFromMoleculeAction
|
|
77
95
|
| ToggleMoleculeViewObjectAction
|
|
78
96
|
| ChangeFloatMoleculePositionAction
|
|
79
|
-
| ChangeMoleculeLabelAction
|
|
97
|
+
| ChangeMoleculeLabelAction
|
|
98
|
+
| ChangeMoleculeAnnotationAction
|
|
99
|
+
| ToggleMoleculeLabelAction;
|
|
80
100
|
|
|
81
101
|
function addMolecule(draft: Draft<State>, props: AddMoleculeProps) {
|
|
82
|
-
const { molfile, id, floatMoleculeOnSave } = props;
|
|
102
|
+
const { molfile, id, floatMoleculeOnSave, defaultMoleculeSettings } = props;
|
|
83
103
|
const isEmpty = draft.molecules.length === 0;
|
|
84
104
|
MoleculeManager.addMolfile(draft.molecules, molfile, id);
|
|
85
105
|
|
|
@@ -94,8 +114,12 @@ function addMolecule(draft: Draft<State>, props: AddMoleculeProps) {
|
|
|
94
114
|
}
|
|
95
115
|
|
|
96
116
|
const lastAddedMolecule = draft.molecules.at(-1);
|
|
97
|
-
if (
|
|
98
|
-
|
|
117
|
+
if (lastAddedMolecule) {
|
|
118
|
+
initMoleculeViewProperties(draft, {
|
|
119
|
+
id: lastAddedMolecule.id,
|
|
120
|
+
defaultMoleculeSettings,
|
|
121
|
+
isMoleculeFloating: floatMoleculeOnSave,
|
|
122
|
+
});
|
|
99
123
|
}
|
|
100
124
|
|
|
101
125
|
return lastAddedMolecule;
|
|
@@ -106,10 +130,10 @@ function handleAddMolecule(draft: Draft<State>, action: AddMoleculeAction) {
|
|
|
106
130
|
addMolecule(draft, action.payload);
|
|
107
131
|
}
|
|
108
132
|
function handleAddMolecules(draft: Draft<State>, action: AddMoleculesAction) {
|
|
109
|
-
const molecules = action.payload
|
|
133
|
+
const { molecules, defaultMoleculeSettings } = action.payload;
|
|
110
134
|
|
|
111
135
|
for (const { molfile } of molecules) {
|
|
112
|
-
addMolecule(draft, { molfile });
|
|
136
|
+
addMolecule(draft, { molfile, defaultMoleculeSettings });
|
|
113
137
|
}
|
|
114
138
|
}
|
|
115
139
|
|
|
@@ -298,19 +322,36 @@ function setPredictedSpectraReference(
|
|
|
298
322
|
draft.view.predictions[moleculeId] = spectraIds;
|
|
299
323
|
}
|
|
300
324
|
|
|
301
|
-
function initMoleculeViewProperties(
|
|
325
|
+
function initMoleculeViewProperties(
|
|
326
|
+
draft: Draft<State>,
|
|
327
|
+
options: {
|
|
328
|
+
id: string;
|
|
329
|
+
defaultMoleculeSettings?: MoleculeView;
|
|
330
|
+
isMoleculeFloating?: boolean;
|
|
331
|
+
},
|
|
332
|
+
) {
|
|
333
|
+
const { id, isMoleculeFloating, defaultMoleculeSettings } = options;
|
|
334
|
+
const { floating, ...otherDefaultOptions } = defaultMoleculeSettings || {};
|
|
335
|
+
const {
|
|
336
|
+
bounding = DRAGGABLE_STRUCTURE_INITIAL_BOUNDING_REACT,
|
|
337
|
+
visible = false,
|
|
338
|
+
...other
|
|
339
|
+
} = floating || {};
|
|
302
340
|
// check if the molecule is exists in the view object otherwise add it with the default value
|
|
303
341
|
if (!draft.view.molecules[id]) {
|
|
304
342
|
const position = getFloatingMoleculeInitialPosition(id, draft);
|
|
305
343
|
draft.view.molecules[id] = {
|
|
344
|
+
atomAnnotation: 'none',
|
|
345
|
+
showLabel: false,
|
|
346
|
+
...otherDefaultOptions,
|
|
306
347
|
floating: {
|
|
307
|
-
visible:
|
|
348
|
+
visible: isMoleculeFloating ?? visible,
|
|
349
|
+
...other,
|
|
308
350
|
bounding: {
|
|
309
|
-
...
|
|
351
|
+
...bounding,
|
|
310
352
|
...position,
|
|
311
353
|
},
|
|
312
354
|
},
|
|
313
|
-
showAtomNumber: false,
|
|
314
355
|
};
|
|
315
356
|
}
|
|
316
357
|
}
|
|
@@ -348,18 +389,6 @@ function getFloatingMoleculeInitialPosition(id: string, draft: Draft<State>) {
|
|
|
348
389
|
};
|
|
349
390
|
}
|
|
350
391
|
|
|
351
|
-
function floatMoleculeOverSpectrum(
|
|
352
|
-
draft: Draft<State>,
|
|
353
|
-
moleculeId: string,
|
|
354
|
-
value?: boolean,
|
|
355
|
-
) {
|
|
356
|
-
initMoleculeViewProperties(moleculeId, draft);
|
|
357
|
-
const molecule = getMoleculeViewObject(moleculeId, draft);
|
|
358
|
-
if (molecule) {
|
|
359
|
-
molecule.floating.visible = value ?? !molecule.floating.visible;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
392
|
//action
|
|
364
393
|
function handleFloatMoleculeOverSpectrum(
|
|
365
394
|
draft: Draft<State>,
|
|
@@ -367,21 +396,25 @@ function handleFloatMoleculeOverSpectrum(
|
|
|
367
396
|
) {
|
|
368
397
|
const { id } = action.payload;
|
|
369
398
|
|
|
370
|
-
|
|
399
|
+
initMoleculeViewProperties(draft, {
|
|
400
|
+
id,
|
|
401
|
+
});
|
|
402
|
+
const view = getMoleculeViewObject(id, draft);
|
|
403
|
+
view.floating.visible = !view.floating.visible;
|
|
371
404
|
}
|
|
372
405
|
|
|
373
406
|
//action
|
|
374
|
-
function
|
|
407
|
+
function handleChangeMoleculeAnnotation(
|
|
375
408
|
draft: Draft<State>,
|
|
376
|
-
action:
|
|
409
|
+
action: ChangeMoleculeAnnotationAction,
|
|
377
410
|
) {
|
|
378
|
-
const { id } = action.payload;
|
|
411
|
+
const { id, atomAnnotation } = action.payload;
|
|
379
412
|
|
|
380
|
-
initMoleculeViewProperties(
|
|
413
|
+
initMoleculeViewProperties(draft, { id });
|
|
381
414
|
const molecule = getMoleculeViewObject(id, draft);
|
|
382
|
-
if (molecule)
|
|
383
|
-
|
|
384
|
-
|
|
415
|
+
if (!molecule) return;
|
|
416
|
+
|
|
417
|
+
molecule.atomAnnotation = atomAnnotation;
|
|
385
418
|
}
|
|
386
419
|
|
|
387
420
|
//action
|
|
@@ -391,11 +424,11 @@ function handleChangeFloatMoleculePosition(
|
|
|
391
424
|
) {
|
|
392
425
|
const { id, bounding } = action.payload;
|
|
393
426
|
const molecule = getMoleculeViewObject(id, draft);
|
|
394
|
-
if (molecule) {
|
|
395
|
-
molecule.floating.bounding = { ...molecule.floating.bounding, ...bounding };
|
|
396
|
-
} else {
|
|
427
|
+
if (!molecule) {
|
|
397
428
|
throw new Error(`Molecule ${id} does not exist`);
|
|
398
429
|
}
|
|
430
|
+
|
|
431
|
+
molecule.floating.bounding = { ...molecule.floating.bounding, ...bounding };
|
|
399
432
|
}
|
|
400
433
|
|
|
401
434
|
//action
|
|
@@ -409,16 +442,31 @@ function handleChangeMoleculeLabel(
|
|
|
409
442
|
);
|
|
410
443
|
draft.molecules[moleculeIndex].label = label;
|
|
411
444
|
}
|
|
445
|
+
//action
|
|
446
|
+
function handleToggleMoleculeLabel(
|
|
447
|
+
draft: Draft<State>,
|
|
448
|
+
action: ToggleMoleculeLabelAction,
|
|
449
|
+
) {
|
|
450
|
+
const { id } = action.payload;
|
|
451
|
+
const molecule = getMoleculeViewObject(id, draft);
|
|
452
|
+
if (!molecule) {
|
|
453
|
+
throw new Error(`Molecule ${id} does not exist`);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
molecule.showLabel = !molecule.showLabel;
|
|
457
|
+
}
|
|
412
458
|
|
|
413
459
|
export {
|
|
414
460
|
addMolecule,
|
|
415
461
|
handleAddMolecule,
|
|
416
462
|
handleAddMolecules,
|
|
417
463
|
handleChangeFloatMoleculePosition,
|
|
464
|
+
handleChangeMoleculeAnnotation,
|
|
418
465
|
handleChangeMoleculeLabel,
|
|
419
466
|
handleDeleteMolecule,
|
|
420
467
|
handleFloatMoleculeOverSpectrum,
|
|
421
468
|
handlePredictSpectraFromMolecule,
|
|
422
469
|
handleSetMolecule,
|
|
423
|
-
|
|
470
|
+
handleToggleMoleculeLabel,
|
|
471
|
+
initMoleculeViewProperties,
|
|
424
472
|
};
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
import type { ChangeRangeRelativeValueProps } from '../../../data/data1d/Spectrum1D/ranges/changeRangeRelativeValue.js';
|
|
30
30
|
import { unlink } from '../../../data/utilities/RangeUtilities.js';
|
|
31
31
|
import { isProton } from '../../../data/utilities/isProton.ts';
|
|
32
|
-
import type { TargetAssignKeys } from '../../panels/MoleculesPanel/
|
|
32
|
+
import type { TargetAssignKeys } from '../../panels/MoleculesPanel/utilities/getAssignIds.ts';
|
|
33
33
|
import type { RangeData } from '../../panels/RangesPanel/hooks/useMapRanges.js';
|
|
34
34
|
import type { FilterType } from '../../utility/filterType.js';
|
|
35
35
|
import type { State } from '../Reducer.js';
|
|
@@ -94,7 +94,15 @@ type AssignRangeAction = ActionType<
|
|
|
94
94
|
{
|
|
95
95
|
keys: TargetAssignKeys;
|
|
96
96
|
spectrumId?: string;
|
|
97
|
-
} & Required<Pick<Range, 'diaIDs' | 'nbAtoms'>>
|
|
97
|
+
} & Required<Pick<Range, 'diaIDs' | 'nbAtoms' | 'assignment'>>
|
|
98
|
+
>;
|
|
99
|
+
type ChangeRangesAssignmentsLabelsByDiaIdsAction = ActionType<
|
|
100
|
+
'CHANGE_ASSIGNMENT_LABEL_BY_DIAIDS',
|
|
101
|
+
{
|
|
102
|
+
diaIDs: string[];
|
|
103
|
+
assignment?: string;
|
|
104
|
+
previousAssignment?: string;
|
|
105
|
+
}
|
|
98
106
|
>;
|
|
99
107
|
type ResizeRangeAction = ActionType<
|
|
100
108
|
'RESIZE_RANGE',
|
|
@@ -179,6 +187,7 @@ export type RangesActions =
|
|
|
179
187
|
| DeleteRangePeakAction
|
|
180
188
|
| ChangeRangeAssignmentLabelAction
|
|
181
189
|
| ChangeRangesViewFloatingBoxBoundingAction
|
|
190
|
+
| ChangeRangesAssignmentsLabelsByDiaIdsAction
|
|
182
191
|
| ActionType<
|
|
183
192
|
| 'AUTO_RANGES_SPECTRA_PICKING'
|
|
184
193
|
| 'CHANGE_RANGES_SUM_FLAG'
|
|
@@ -429,7 +438,7 @@ function handleUnlinkRange(draft: Draft<State>, action: UnlinkRangeAction) {
|
|
|
429
438
|
|
|
430
439
|
//action
|
|
431
440
|
function handleAssignRange(draft: Draft<State>, action: AssignRangeAction) {
|
|
432
|
-
const { keys, diaIDs, nbAtoms, spectrumId } = action.payload;
|
|
441
|
+
const { keys, diaIDs, nbAtoms, spectrumId, assignment } = action.payload;
|
|
433
442
|
|
|
434
443
|
const spectrum = getSpectrum(draft, spectrumId);
|
|
435
444
|
|
|
@@ -443,6 +452,10 @@ function handleAssignRange(draft: Draft<State>, action: AssignRangeAction) {
|
|
|
443
452
|
|
|
444
453
|
range.diaIDs = diaIDs;
|
|
445
454
|
range.nbAtoms = nbAtoms + (range.nbAtoms || 0);
|
|
455
|
+
|
|
456
|
+
if (assignment && !range.assignment) {
|
|
457
|
+
range.assignment = assignment;
|
|
458
|
+
}
|
|
446
459
|
} else {
|
|
447
460
|
const [{ index: rangeIndex }, { index: signalIndex }] = keys;
|
|
448
461
|
const range = spectrum.ranges.values[rangeIndex];
|
|
@@ -456,10 +469,41 @@ function handleAssignRange(draft: Draft<State>, action: AssignRangeAction) {
|
|
|
456
469
|
signal.diaIDs = diaIDs;
|
|
457
470
|
signal.nbAtoms = nbAtoms + (signal.nbAtoms || 0);
|
|
458
471
|
}
|
|
459
|
-
|
|
460
|
-
// _range.nbAtoms = getNbAtoms(_range);
|
|
461
472
|
}
|
|
473
|
+
//action
|
|
474
|
+
function handleChangeRangesAssignmentLabelsByDiaIds(
|
|
475
|
+
draft: Draft<State>,
|
|
476
|
+
action: ChangeRangesAssignmentsLabelsByDiaIdsAction,
|
|
477
|
+
) {
|
|
478
|
+
const { diaIDs, assignment, previousAssignment } = action.payload;
|
|
479
|
+
|
|
480
|
+
const uniqueDiaIds = new Set(diaIDs);
|
|
481
|
+
|
|
482
|
+
const spectrum = getSpectrum(draft);
|
|
462
483
|
|
|
484
|
+
if (!spectrum || !isSpectrum1D(spectrum)) return;
|
|
485
|
+
|
|
486
|
+
const {
|
|
487
|
+
ranges: { values },
|
|
488
|
+
} = spectrum;
|
|
489
|
+
|
|
490
|
+
for (const range of values) {
|
|
491
|
+
const { diaIDs: rangeDiaIDs = [], signals = [] } = range;
|
|
492
|
+
|
|
493
|
+
const matchesRange = rangeDiaIDs.some((id) => uniqueDiaIds.has(id));
|
|
494
|
+
const matchesSignals = signals.some((s) =>
|
|
495
|
+
s.diaIDs?.some((id) => uniqueDiaIds.has(id)),
|
|
496
|
+
);
|
|
497
|
+
|
|
498
|
+
if (
|
|
499
|
+
((!range.assignment || previousAssignment === range.assignment) &&
|
|
500
|
+
matchesRange) ||
|
|
501
|
+
matchesSignals
|
|
502
|
+
) {
|
|
503
|
+
range.assignment = assignment;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
463
507
|
//action
|
|
464
508
|
function handleResizeRange(draft: Draft<State>, action: ResizeRangeAction) {
|
|
465
509
|
const { range, spectrumKey } = action.payload;
|
|
@@ -714,6 +758,7 @@ export {
|
|
|
714
758
|
handleChangeRangeSignalKind,
|
|
715
759
|
handleChangeRangeSignalValue,
|
|
716
760
|
handleChangeRangeSum,
|
|
761
|
+
handleChangeRangesAssignmentLabelsByDiaIds,
|
|
717
762
|
handleChangeRangesSumFlag,
|
|
718
763
|
handleChangeRangesViewFloatingBoxBounding,
|
|
719
764
|
handleCutRange,
|
|
@@ -26,7 +26,7 @@ import type { DetectionZonesOptions } from '../../../data/data2d/Spectrum2D/zone
|
|
|
26
26
|
import { unlink } from '../../../data/utilities/ZoneUtilities.js';
|
|
27
27
|
import type { Axis } from '../../assignment/AssignmentsContext.js';
|
|
28
28
|
import { defaultZonesViewState } from '../../hooks/useActiveSpectrumZonesViewState.js';
|
|
29
|
-
import type { TargetAssignKeys } from '../../panels/MoleculesPanel/
|
|
29
|
+
import type { TargetAssignKeys } from '../../panels/MoleculesPanel/utilities/getAssignIds.ts';
|
|
30
30
|
import type { ZoneData } from '../../panels/ZonesPanel/hooks/useMapZones.js';
|
|
31
31
|
import type { FilterType } from '../../utility/filterType.js';
|
|
32
32
|
import type { State } from '../Reducer.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Draft } from 'immer';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ChangeDefaultMoleculeSettingsAction,
|
|
5
|
+
PreferencesState,
|
|
6
|
+
} from '../preferencesReducer.js';
|
|
7
|
+
import { getActiveWorkspace } from '../utilities/getActiveWorkspace.js';
|
|
8
|
+
|
|
9
|
+
export function changeDefaultMoleculeSettings(
|
|
10
|
+
draft: Draft<PreferencesState>,
|
|
11
|
+
action: ChangeDefaultMoleculeSettingsAction,
|
|
12
|
+
) {
|
|
13
|
+
const currentWorkspacePreferences = getActiveWorkspace(draft);
|
|
14
|
+
const settings = action.payload;
|
|
15
|
+
currentWorkspacePreferences.defaultMoleculeSettings = settings;
|
|
16
|
+
}
|