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
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { MoleculeView } from '@zakodium/nmrium-core';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import type { MolfileSvgRendererProps } from 'react-ocl';
|
|
4
|
+
import { MolfileSvgRenderer } from 'react-ocl';
|
|
5
|
+
import type { OCLnmrProps } from 'react-ocl-nmr';
|
|
6
|
+
import OCLnmr from 'react-ocl-nmr';
|
|
7
|
+
|
|
8
|
+
import type { StateMoleculeExtended } from '../../../data/molecules/Molecule.ts';
|
|
9
|
+
import { useDispatch } from '../../context/DispatchContext.tsx';
|
|
10
|
+
import { useHighlightColor } from '../../hooks/useHighlightColor.ts';
|
|
11
|
+
|
|
12
|
+
import useAtomAssignment from './hooks/useAtomAssignment.tsx';
|
|
13
|
+
import { useExtractAtomAssignmentLabel } from './hooks/useExtractAtomAssignmentLabel.ts';
|
|
14
|
+
|
|
15
|
+
interface MoleculeStructureProps extends Pick<OCLnmrProps, 'width' | 'height'> {
|
|
16
|
+
moleculeView: MoleculeView;
|
|
17
|
+
renderAsSVG?: boolean;
|
|
18
|
+
molecule: StateMoleculeExtended;
|
|
19
|
+
showMoleculeLabel?: boolean;
|
|
20
|
+
index?: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function MoleculeStructure(props: MoleculeStructureProps) {
|
|
24
|
+
const {
|
|
25
|
+
molecule,
|
|
26
|
+
moleculeView,
|
|
27
|
+
width,
|
|
28
|
+
height,
|
|
29
|
+
renderAsSVG = false,
|
|
30
|
+
showMoleculeLabel,
|
|
31
|
+
index = 0,
|
|
32
|
+
} = props;
|
|
33
|
+
const {
|
|
34
|
+
currentDiaIDsToHighlight,
|
|
35
|
+
handleOnAtomHover,
|
|
36
|
+
handleOnClickAtom,
|
|
37
|
+
assignedDiaIDsMerged,
|
|
38
|
+
} = useAtomAssignment();
|
|
39
|
+
const highlightColor = useHighlightColor();
|
|
40
|
+
const dispatch = useDispatch();
|
|
41
|
+
const { onAtomHover, getAssignmentLabelByHover, getLastHoverAtom } =
|
|
42
|
+
useExtractAtomAssignmentLabel();
|
|
43
|
+
//TODO Temporary workaround to prevent other focused elements from being triggered by the space key
|
|
44
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
45
|
+
|
|
46
|
+
const atomHighlightColor =
|
|
47
|
+
currentDiaIDsToHighlight?.length > 0 ? '#ff000080' : highlightColor;
|
|
48
|
+
const baseProps: MolfileSvgRendererProps = {
|
|
49
|
+
height,
|
|
50
|
+
width,
|
|
51
|
+
label: (showMoleculeLabel ?? moleculeView.showLabel) ? molecule.label : '',
|
|
52
|
+
labelFontSize: 15,
|
|
53
|
+
labelColor: 'rgba(138, 59, 59, 1)',
|
|
54
|
+
molfile: molecule.molfile,
|
|
55
|
+
atomHighlightColor,
|
|
56
|
+
atomHighlightOpacity: 1,
|
|
57
|
+
showAtomNumber: moleculeView.atomAnnotation === 'atom-numbers',
|
|
58
|
+
noAtomCustomLabels: moleculeView.atomAnnotation !== 'custom-labels',
|
|
59
|
+
noCarbonLabelWithCustomLabel: true,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (renderAsSVG) {
|
|
63
|
+
return <MolfileSvgRenderer {...baseProps} />;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<div tabIndex={0} ref={containerRef}>
|
|
68
|
+
<OCLnmr
|
|
69
|
+
id={`molSVG${index}`}
|
|
70
|
+
{...baseProps}
|
|
71
|
+
setSelectedAtom={(atom, event) =>
|
|
72
|
+
handleOnClickAtom(atom, event, molecule.id)
|
|
73
|
+
}
|
|
74
|
+
highlights={
|
|
75
|
+
currentDiaIDsToHighlight?.length > 0
|
|
76
|
+
? currentDiaIDsToHighlight
|
|
77
|
+
: assignedDiaIDsMerged
|
|
78
|
+
}
|
|
79
|
+
atomHighlightStrategy="prefer-editor-props"
|
|
80
|
+
setHoverAtom={(atom) => {
|
|
81
|
+
//TODO Temporary workaround to prevent other focused elements from being triggered by the space key
|
|
82
|
+
containerRef.current?.focus();
|
|
83
|
+
handleOnAtomHover(atom);
|
|
84
|
+
if (atom) {
|
|
85
|
+
onAtomHover(atom);
|
|
86
|
+
}
|
|
87
|
+
}}
|
|
88
|
+
setMolfile={(molfile) => {
|
|
89
|
+
const diaObject = getLastHoverAtom();
|
|
90
|
+
const assignmentObj = getAssignmentLabelByHover(molecule.id, molfile);
|
|
91
|
+
|
|
92
|
+
if (assignmentObj && diaObject) {
|
|
93
|
+
dispatch({
|
|
94
|
+
type: 'CHANGE_ASSIGNMENT_LABEL_BY_DIAIDS',
|
|
95
|
+
payload: {
|
|
96
|
+
diaIDs: [diaObject.idCode].concat(
|
|
97
|
+
diaObject.attachedHydrogensIDCodes,
|
|
98
|
+
),
|
|
99
|
+
assignment: assignmentObj.assignment,
|
|
100
|
+
previousAssignment: assignmentObj.previousAssignment,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
dispatch({
|
|
106
|
+
type: 'SET_MOLECULE',
|
|
107
|
+
payload: {
|
|
108
|
+
molfile,
|
|
109
|
+
id: molecule.id,
|
|
110
|
+
label: molecule.label,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
}}
|
|
114
|
+
/>
|
|
115
|
+
</div>
|
|
116
|
+
);
|
|
117
|
+
}
|
package/src/component/panels/MoleculesPanel/{useAtomAssignment.tsx → hooks/useAtomAssignment.tsx}
RENAMED
|
@@ -3,28 +3,30 @@ import type { DiaIDAndInfo } from 'openchemlib-utils';
|
|
|
3
3
|
import type { MouseEvent } from 'react';
|
|
4
4
|
import { useMemo, useRef } from 'react';
|
|
5
5
|
|
|
6
|
-
import { isSpectrum1D } from '
|
|
7
|
-
import { isSpectrum2D } from '
|
|
8
|
-
import { ConcatenationString } from '
|
|
9
|
-
import checkModifierKeyActivated from '
|
|
10
|
-
import { useTracesSpectra } from '
|
|
11
|
-
import type {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} from '
|
|
6
|
+
import { isSpectrum1D } from '../../../../data/data1d/Spectrum1D/isSpectrum1D.ts';
|
|
7
|
+
import { isSpectrum2D } from '../../../../data/data2d/Spectrum2D/isSpectrum2D.ts';
|
|
8
|
+
import { ConcatenationString } from '../../../../data/utilities/Concatenation.ts';
|
|
9
|
+
import checkModifierKeyActivated from '../../../../data/utilities/checkModifierKeyActivated.ts';
|
|
10
|
+
import { useTracesSpectra } from '../../../2d/useTracesSpectra.ts';
|
|
11
|
+
import type {
|
|
12
|
+
Assignments,
|
|
13
|
+
Axis,
|
|
14
|
+
} from '../../../assignment/AssignmentsContext.ts';
|
|
15
|
+
import { useAssignmentContext } from '../../../assignment/AssignmentsContext.ts';
|
|
16
|
+
import { useChartData } from '../../../context/ChartContext.tsx';
|
|
17
|
+
import { useDispatch } from '../../../context/DispatchContext.tsx';
|
|
18
|
+
import { useToaster } from '../../../context/ToasterContext.tsx';
|
|
19
|
+
import type { HighlightEventSource } from '../../../highlight/index.tsx';
|
|
20
|
+
import { useHighlightData } from '../../../highlight/index.tsx';
|
|
21
|
+
import useSpectrum from '../../../hooks/useSpectrum.ts';
|
|
22
|
+
import type { AtomData } from '../utilities/AtomData.ts';
|
|
23
|
+
import { extractFromAtom } from '../utilities/extractFromAtom.ts';
|
|
24
|
+
import { getAssignIds } from '../utilities/getAssignIds.ts';
|
|
25
|
+
import { getCurrentDiaIDsToHighlight } from '../utilities/getCurrentDiaIDsToHighlight.ts';
|
|
26
|
+
import { getHighlightsOnHover } from '../utilities/getHighlightsOnHover.ts';
|
|
27
|
+
import { getUniqueDiaIDs } from '../utilities/getUniqueDiaIDs.ts';
|
|
28
|
+
|
|
29
|
+
import { useExtractAtomAssignmentLabel } from './useExtractAtomAssignmentLabel.ts';
|
|
28
30
|
|
|
29
31
|
function flattenAssignedDiaIDs(assignments: Assignments) {
|
|
30
32
|
const assignedDiaIDs: string[] = [];
|
|
@@ -84,6 +86,7 @@ export default function useAtomAssignment() {
|
|
|
84
86
|
const highlightData = useHighlightData();
|
|
85
87
|
const highlightedIdDsRef = useRef<string[]>([]);
|
|
86
88
|
const assignments = useAssignmentContext();
|
|
89
|
+
const { getAssignmentLabelById } = useExtractAtomAssignmentLabel();
|
|
87
90
|
const { activated: activatedAssignment } = assignments;
|
|
88
91
|
|
|
89
92
|
const activatedKey = activatedAssignment
|
|
@@ -126,8 +129,16 @@ export default function useAtomAssignment() {
|
|
|
126
129
|
return getCurrentDiaIDsToHighlight(assignments).concat(highlights);
|
|
127
130
|
}, [assignments, highlightData.highlight, spectrum, tracesSpectra]);
|
|
128
131
|
|
|
129
|
-
|
|
130
|
-
|
|
132
|
+
interface Assign1DOptions {
|
|
133
|
+
spectrum: Spectrum1D;
|
|
134
|
+
assignId: string;
|
|
135
|
+
atom: AtomData;
|
|
136
|
+
assignmentLabel?: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function assign1DAtom(options: Assign1DOptions) {
|
|
140
|
+
const { spectrum, assignId, atom, assignmentLabel } = options;
|
|
141
|
+
const assignKeys = getAssignIds(spectrum, assignId);
|
|
131
142
|
|
|
132
143
|
if (!assignKeys) return;
|
|
133
144
|
const [{ index: rangeIndex }] = assignKeys;
|
|
@@ -154,6 +165,7 @@ export default function useAtomAssignment() {
|
|
|
154
165
|
diaIDs: uniqueDiaIDs.diaIDs,
|
|
155
166
|
keys: assignKeys,
|
|
156
167
|
spectrumId,
|
|
168
|
+
assignment: assignmentLabel || '',
|
|
157
169
|
},
|
|
158
170
|
});
|
|
159
171
|
}
|
|
@@ -193,6 +205,7 @@ export default function useAtomAssignment() {
|
|
|
193
205
|
function handleOnClickAtom(
|
|
194
206
|
diaIDAndInfo: DiaIDAndInfo | undefined,
|
|
195
207
|
event: MouseEvent,
|
|
208
|
+
moleculeId: string,
|
|
196
209
|
) {
|
|
197
210
|
if (checkModifierKeyActivated(event) || !activatedAssignment) return;
|
|
198
211
|
|
|
@@ -202,6 +215,10 @@ export default function useAtomAssignment() {
|
|
|
202
215
|
if (!id || !axis) {
|
|
203
216
|
return;
|
|
204
217
|
}
|
|
218
|
+
|
|
219
|
+
const assignmentLabel = diaIDAndInfo?.idCode
|
|
220
|
+
? getAssignmentLabelById(moleculeId, diaIDAndInfo.idCode)
|
|
221
|
+
: '';
|
|
205
222
|
const atomInformation = extractFromAtom(diaIDAndInfo, nucleus, axis);
|
|
206
223
|
|
|
207
224
|
if (atomInformation.nbAtoms === 0) {
|
|
@@ -226,7 +243,12 @@ export default function useAtomAssignment() {
|
|
|
226
243
|
if (!currentSpectrum) return;
|
|
227
244
|
|
|
228
245
|
if (isSpectrum1D(currentSpectrum)) {
|
|
229
|
-
assign1DAtom(
|
|
246
|
+
assign1DAtom({
|
|
247
|
+
spectrum: currentSpectrum,
|
|
248
|
+
assignId: activatedAssignment.id,
|
|
249
|
+
atom: atomInformation,
|
|
250
|
+
assignmentLabel,
|
|
251
|
+
});
|
|
230
252
|
} else {
|
|
231
253
|
assign2DAtom(
|
|
232
254
|
currentSpectrum,
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Molecule } from 'openchemlib';
|
|
2
|
+
import type { DiaIDAndInfo } from 'openchemlib-utils';
|
|
3
|
+
import { useRef } from 'react';
|
|
4
|
+
|
|
5
|
+
import { useTopicMolecule } from '../../../context/TopicMoleculeContext.tsx';
|
|
6
|
+
|
|
7
|
+
export function useExtractAtomAssignmentLabel() {
|
|
8
|
+
const topicMolecule = useTopicMolecule();
|
|
9
|
+
const lastHoverAtomIdRef = useRef<DiaIDAndInfo>();
|
|
10
|
+
|
|
11
|
+
function getLastHoverAtom() {
|
|
12
|
+
return lastHoverAtomIdRef.current;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getTopicAtom(moleculeId: string, oclId: string, molfile?: string) {
|
|
16
|
+
const baseMolecule = topicMolecule?.[moleculeId];
|
|
17
|
+
|
|
18
|
+
if (!baseMolecule) return;
|
|
19
|
+
|
|
20
|
+
const molecule = molfile
|
|
21
|
+
? baseMolecule.fromMolecule(Molecule.fromMolfile(molfile))
|
|
22
|
+
: baseMolecule;
|
|
23
|
+
|
|
24
|
+
const groupedDiaIdsMapping = molecule.getGroupedDiastereotopicAtomIDs();
|
|
25
|
+
if (!Array.isArray(groupedDiaIdsMapping)) return;
|
|
26
|
+
|
|
27
|
+
return groupedDiaIdsMapping.find((obj: any) => obj.oclID === oclId);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getTopicAtomByHover(moleculeId: string, molfile?: string) {
|
|
31
|
+
if (!lastHoverAtomIdRef.current) return;
|
|
32
|
+
|
|
33
|
+
return getTopicAtom(moleculeId, lastHoverAtomIdRef.current.idCode, molfile);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function onAtomHover(atom: DiaIDAndInfo | undefined) {
|
|
37
|
+
lastHoverAtomIdRef.current = atom;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function getAssignmentLabelById(
|
|
41
|
+
moleculeId: string,
|
|
42
|
+
oclID: string,
|
|
43
|
+
molfile?: string,
|
|
44
|
+
) {
|
|
45
|
+
const atomData = getTopicAtom(moleculeId, oclID, molfile);
|
|
46
|
+
if (!atomData) return;
|
|
47
|
+
|
|
48
|
+
const { customLabels = [], heavyAtomsCustomLabels = [] } = atomData;
|
|
49
|
+
const labels =
|
|
50
|
+
customLabels.length > 0 ? customLabels : heavyAtomsCustomLabels;
|
|
51
|
+
|
|
52
|
+
const uniqueLabels = [
|
|
53
|
+
...new Set(labels.map((l: string) => l.trim()).filter(Boolean)),
|
|
54
|
+
];
|
|
55
|
+
return uniqueLabels.join(',');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function getAssignmentLabelByHover(moleculeId: string, molfile?: string) {
|
|
59
|
+
const diaId = lastHoverAtomIdRef.current?.idCode;
|
|
60
|
+
if (!diaId) return;
|
|
61
|
+
return {
|
|
62
|
+
assignment: getAssignmentLabelById(moleculeId, diaId, molfile),
|
|
63
|
+
previousAssignment: getAssignmentLabelById(moleculeId, diaId),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
getAssignmentLabelByHover,
|
|
69
|
+
getAssignmentLabelById,
|
|
70
|
+
onAtomHover,
|
|
71
|
+
getLastHoverAtom,
|
|
72
|
+
getTopicAtomByHover,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { DiaIDAndInfo } from 'openchemlib-utils';
|
|
2
|
+
|
|
3
|
+
import type { Axis } from '../../../assignment/AssignmentsContext.js';
|
|
4
|
+
|
|
5
|
+
import type { AtomData } from './AtomData.ts';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns the OCL id(s) and number of atoms of an atom when hovering over
|
|
9
|
+
* or clicking on it. This is depending on an optional given axis.
|
|
10
|
+
* In case of an heavy atom with bonded hydrogens the OCL id(s)
|
|
11
|
+
* and number of these hydrogens are added as well.
|
|
12
|
+
*
|
|
13
|
+
* @param {DiaIDAndInfo} diaIDAndInfo - atom returned by OCLnmr component
|
|
14
|
+
* @param {string} activeTab - active tab
|
|
15
|
+
* @param {Axis} axis - current axis
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
export function extractFromAtom(
|
|
19
|
+
diaIDAndInfo: DiaIDAndInfo | undefined,
|
|
20
|
+
activeTab: string,
|
|
21
|
+
axis?: Axis | null,
|
|
22
|
+
): AtomData {
|
|
23
|
+
const elements = getElements(activeTab);
|
|
24
|
+
|
|
25
|
+
if (elements && elements.length > 0 && diaIDAndInfo) {
|
|
26
|
+
const dim = axis === 'x' ? 0 : axis === 'y' ? 1 : null;
|
|
27
|
+
switch (dim !== null && elements[dim]) {
|
|
28
|
+
case diaIDAndInfo.atomLabel: {
|
|
29
|
+
// take always oclID if atom type is same as element of activeTab)
|
|
30
|
+
return {
|
|
31
|
+
oclIDs: [diaIDAndInfo.idCode],
|
|
32
|
+
nbAtoms: diaIDAndInfo.nbEquivalentAtoms,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
case 'H': {
|
|
36
|
+
// if we are in proton spectrum and use then the IDs of attached hydrogens of an atom
|
|
37
|
+
return {
|
|
38
|
+
oclIDs: diaIDAndInfo.attachedHydrogensIDCodes,
|
|
39
|
+
nbAtoms:
|
|
40
|
+
diaIDAndInfo.nbEquivalentAtoms * diaIDAndInfo.nbAttachedHydrogens,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
default:
|
|
44
|
+
return {
|
|
45
|
+
oclIDs: [diaIDAndInfo.idCode].concat(
|
|
46
|
+
diaIDAndInfo.attachedHydrogensIDCodes,
|
|
47
|
+
),
|
|
48
|
+
nbAtoms:
|
|
49
|
+
diaIDAndInfo.nbEquivalentAtoms +
|
|
50
|
+
diaIDAndInfo.nbEquivalentAtoms * diaIDAndInfo.nbAttachedHydrogens,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return { oclIDs: [], nbAtoms: 0 };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function getElements(activeTab: string) {
|
|
59
|
+
if (!activeTab) return;
|
|
60
|
+
|
|
61
|
+
const nuclei = activeTab.split(',');
|
|
62
|
+
return nuclei.map((nucleus) => nucleus.replaceAll(/\d/g, ''));
|
|
63
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Range, Zone } from '@zakodium/nmr-types';
|
|
2
|
+
import type { Spectrum } from '@zakodium/nmrium-core';
|
|
3
|
+
|
|
4
|
+
import { isSpectrum1D } from '../../../../data/data1d/Spectrum1D/isSpectrum1D.ts';
|
|
5
|
+
|
|
6
|
+
interface TargetAssignment {
|
|
7
|
+
key: string;
|
|
8
|
+
index: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface RangeTargetAssignKey extends TargetAssignment {
|
|
12
|
+
target: 'range';
|
|
13
|
+
}
|
|
14
|
+
interface ZoneTargetAssignKey extends TargetAssignment {
|
|
15
|
+
target: 'zone';
|
|
16
|
+
}
|
|
17
|
+
interface SignalTargetAssignKey extends TargetAssignment {
|
|
18
|
+
target: 'signal';
|
|
19
|
+
}
|
|
20
|
+
export type TargetAssignKeys =
|
|
21
|
+
| [RangeTargetAssignKey | ZoneTargetAssignKey]
|
|
22
|
+
| [RangeTargetAssignKey | ZoneTargetAssignKey, SignalTargetAssignKey];
|
|
23
|
+
|
|
24
|
+
export function getAssignIds(
|
|
25
|
+
spectrum: Spectrum,
|
|
26
|
+
id: string,
|
|
27
|
+
): TargetAssignKeys | null {
|
|
28
|
+
if (!spectrum) return null;
|
|
29
|
+
|
|
30
|
+
const data = getRangesOrZones(spectrum);
|
|
31
|
+
const target = isSpectrum1D(spectrum) ? 'range' : 'zone';
|
|
32
|
+
|
|
33
|
+
for (let i = 0; i < data.length; i++) {
|
|
34
|
+
const datum = data[i];
|
|
35
|
+
|
|
36
|
+
if (datum.id === id) {
|
|
37
|
+
return [{ target, index: i, key: datum.id }];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const signalIndex = datum.signals.findIndex((signal) => signal.id === id);
|
|
41
|
+
if (signalIndex !== -1) {
|
|
42
|
+
const { id } = datum.signals[signalIndex];
|
|
43
|
+
return [
|
|
44
|
+
{ target, index: i, key: datum.id },
|
|
45
|
+
{ target: 'signal', index: signalIndex, key: id },
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function getRangesOrZones(spectrum: Spectrum): Array<Range | Zone> {
|
|
54
|
+
if (isSpectrum1D(spectrum)) {
|
|
55
|
+
return spectrum.ranges.values;
|
|
56
|
+
} else {
|
|
57
|
+
return spectrum.zones.values;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AssignmentContext } from '../../../assignment/AssignmentsContext.ts';
|
|
2
|
+
|
|
3
|
+
export function getCurrentDiaIDsToHighlight(assignmentData: AssignmentContext) {
|
|
4
|
+
const { highlighted, data } = assignmentData;
|
|
5
|
+
const assignment = highlighted ? data[highlighted.id] : null;
|
|
6
|
+
const axisHover = highlighted ? highlighted.axis : null;
|
|
7
|
+
if (axisHover && assignment?.[axisHover]) {
|
|
8
|
+
return assignment[axisHover];
|
|
9
|
+
} else {
|
|
10
|
+
return (assignment?.x || []).concat(assignment?.y || []);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Spectrum } from '@zakodium/nmrium-core';
|
|
2
|
+
|
|
3
|
+
import { assignmentAxes } from '../../../assignment/AssignmentsContext.js';
|
|
4
|
+
import type { AssignmentContext } from '../../../assignment/AssignmentsContext.ts';
|
|
5
|
+
|
|
6
|
+
import { getAssignIds } from './getAssignIds.ts';
|
|
7
|
+
|
|
8
|
+
export function getHighlightsOnHover(
|
|
9
|
+
assignments: AssignmentContext,
|
|
10
|
+
oclIDs: string[],
|
|
11
|
+
spectra: Spectrum[],
|
|
12
|
+
) {
|
|
13
|
+
// set all IDs to highlight when hovering over an atom from AssignKey data
|
|
14
|
+
let highlights: string[] = [];
|
|
15
|
+
const assignmentsByKey = assignments.data;
|
|
16
|
+
|
|
17
|
+
for (const key in assignmentsByKey) {
|
|
18
|
+
const assignments = assignmentsByKey[key];
|
|
19
|
+
for (const axis of assignmentAxes) {
|
|
20
|
+
if (assignments[axis]?.some((oclKey: any) => oclIDs.includes(oclKey))) {
|
|
21
|
+
highlights = highlights.concat(assignments[axis]);
|
|
22
|
+
for (const spectrum of spectra) {
|
|
23
|
+
const assignIds = getAssignIds(spectrum, key);
|
|
24
|
+
if (!assignIds) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const ids = assignIds.map<string>((item) => item.key);
|
|
29
|
+
highlights.push(...ids);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return highlights;
|
|
36
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AtomData } from './AtomData.ts';
|
|
2
|
+
|
|
3
|
+
export function getUniqueDiaIDs(diaIDs: string[], atomInformation: AtomData) {
|
|
4
|
+
// a previous version of the code prevented to assign many time the same atom
|
|
5
|
+
// see revision cc13abc18f77b6787b923e3c4edaef51750d9e90
|
|
6
|
+
const { nbAtoms, oclIDs } = atomInformation;
|
|
7
|
+
|
|
8
|
+
const diaIDSet = new Set(diaIDs);
|
|
9
|
+
let tempNbAtoms: number = nbAtoms;
|
|
10
|
+
|
|
11
|
+
for (const oclID of oclIDs) {
|
|
12
|
+
if (diaIDSet.has(oclID)) {
|
|
13
|
+
tempNbAtoms *= -1;
|
|
14
|
+
diaIDSet.delete(oclID);
|
|
15
|
+
} else {
|
|
16
|
+
diaIDSet.add(oclID);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return { diaIDs: Array.from(diaIDSet), nbAtoms: tempNbAtoms };
|
|
20
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
import type { DatabaseNMREntry } from 'nmr-processing';
|
|
3
|
+
|
|
4
|
+
import { filterDatabaseInfoEntry } from '../../utility/filterDatabaseInfoEntry.ts';
|
|
5
|
+
|
|
6
|
+
const Container = styled.div`
|
|
7
|
+
display: flex;
|
|
8
|
+
`;
|
|
9
|
+
|
|
10
|
+
const Column = styled.div`
|
|
11
|
+
padding: 5px;
|
|
12
|
+
color: white;
|
|
13
|
+
border-radius: 5px;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
margin: 2px 0;
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const Key = styled(Column)`
|
|
20
|
+
background-color: rgb(0 0 0 / 10%);
|
|
21
|
+
flex: 1;
|
|
22
|
+
margin-right: 5px;
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
export function DatabaseInfo(props: { data: DatabaseNMREntry }) {
|
|
26
|
+
const { data } = props;
|
|
27
|
+
const meta = filterDatabaseInfoEntry(data);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Container>
|
|
31
|
+
<Column>
|
|
32
|
+
{Object.keys(meta).map((key, index) => {
|
|
33
|
+
return <Key key={index}>{key}</Key>;
|
|
34
|
+
})}
|
|
35
|
+
</Column>
|
|
36
|
+
<Column>
|
|
37
|
+
{Object.keys(meta).map((key, index) => {
|
|
38
|
+
return <Column key={index}>{meta[key]}</Column>;
|
|
39
|
+
})}
|
|
40
|
+
</Column>
|
|
41
|
+
</Container>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Classes } from '@blueprintjs/core';
|
|
2
2
|
import dlv from 'dlv';
|
|
3
|
+
import type { DatabaseNMREntry } from 'nmr-processing';
|
|
3
4
|
import type { CSSProperties } from 'react';
|
|
4
5
|
import { memo, useMemo } from 'react';
|
|
5
6
|
import { ResponsiveChart } from 'react-d3-utils';
|
|
6
|
-
import { FaDownload, FaMinus, FaPlus } from 'react-icons/fa';
|
|
7
|
+
import { FaDownload, FaInfoCircle, FaMinus, FaPlus } from 'react-icons/fa';
|
|
7
8
|
import { IdcodeSvgRenderer, SmilesSvgRenderer } from 'react-ocl';
|
|
8
9
|
import { Button } from 'react-science/ui';
|
|
9
10
|
import type { CellProps } from 'react-table';
|
|
@@ -18,6 +19,8 @@ import { usePanelPreferences } from '../../hooks/usePanelPreferences.js';
|
|
|
18
19
|
import useSpectraByActiveNucleus from '../../hooks/useSpectraPerNucleus.js';
|
|
19
20
|
import { formatNumber } from '../../utility/formatNumber.js';
|
|
20
21
|
|
|
22
|
+
import { DatabaseInfo } from './DatabaseInfo.tsx';
|
|
23
|
+
|
|
21
24
|
interface ToggleEvent {
|
|
22
25
|
onAdd: (row: any) => void;
|
|
23
26
|
onRemove: (row: any) => void;
|
|
@@ -144,6 +147,7 @@ const databaseTableColumns = (
|
|
|
144
147
|
width={width}
|
|
145
148
|
idcode={idCode}
|
|
146
149
|
coordinates={coordinates}
|
|
150
|
+
noAtomCustomLabels
|
|
147
151
|
/>
|
|
148
152
|
);
|
|
149
153
|
} else if (smiles) {
|
|
@@ -152,6 +156,7 @@ const databaseTableColumns = (
|
|
|
152
156
|
height={height}
|
|
153
157
|
width={width}
|
|
154
158
|
smiles={smiles}
|
|
159
|
+
noAtomCustomLabels
|
|
155
160
|
/>
|
|
156
161
|
);
|
|
157
162
|
} else {
|
|
@@ -177,6 +182,33 @@ function DatabaseTable({
|
|
|
177
182
|
|
|
178
183
|
const initialColumns = useMemo<ColumnDef[]>(
|
|
179
184
|
() => [
|
|
185
|
+
{
|
|
186
|
+
index: 0,
|
|
187
|
+
id: 'meta',
|
|
188
|
+
Header: '',
|
|
189
|
+
style: {
|
|
190
|
+
width: '1%',
|
|
191
|
+
maxWidth: '25px',
|
|
192
|
+
minWidth: '25px',
|
|
193
|
+
padding: 0,
|
|
194
|
+
},
|
|
195
|
+
Cell: ({ row }: CellProps<PrepareDataResult>) => {
|
|
196
|
+
return (
|
|
197
|
+
<Button
|
|
198
|
+
style={{ padding: 0 }}
|
|
199
|
+
minimal
|
|
200
|
+
small
|
|
201
|
+
icon={<FaInfoCircle />}
|
|
202
|
+
tooltipProps={{
|
|
203
|
+
content: (
|
|
204
|
+
<DatabaseInfo data={row.original as DatabaseNMREntry} />
|
|
205
|
+
),
|
|
206
|
+
}}
|
|
207
|
+
/>
|
|
208
|
+
);
|
|
209
|
+
},
|
|
210
|
+
enableRowSpan: true,
|
|
211
|
+
},
|
|
180
212
|
{
|
|
181
213
|
index: 10,
|
|
182
214
|
id: 'add-button',
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { MoleculeView } from '@zakodium/nmrium-core';
|
|
2
|
+
|
|
3
|
+
import { useDispatch } from '../../context/DispatchContext.tsx';
|
|
4
|
+
|
|
5
|
+
type Annotation = MoleculeView['atomAnnotation'];
|
|
6
|
+
|
|
7
|
+
export function useMoleculeAnnotationCore(
|
|
8
|
+
id: string,
|
|
9
|
+
moleculeView: MoleculeView,
|
|
10
|
+
) {
|
|
11
|
+
const dispatch = useDispatch();
|
|
12
|
+
const { atomAnnotation: baseAtomAnnotation } = moleculeView || {};
|
|
13
|
+
function isAnnotation(annotation: Annotation) {
|
|
14
|
+
return baseAtomAnnotation === annotation;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function handleChangeAtomAnnotation(annotation: Annotation) {
|
|
18
|
+
const atomAnnotation =
|
|
19
|
+
baseAtomAnnotation === annotation ? 'none' : annotation;
|
|
20
|
+
dispatch({
|
|
21
|
+
type: 'CHANGE_MOLECULE_ANNOTATION',
|
|
22
|
+
payload: { id, atomAnnotation },
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function handleToggleMoleculeLabel() {
|
|
26
|
+
dispatch({
|
|
27
|
+
type: 'TOGGLE_MOLECULE_LABEL',
|
|
28
|
+
payload: { id },
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
handleToggleMoleculeLabel,
|
|
33
|
+
isAnnotation,
|
|
34
|
+
handleChangeAtomAnnotation,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -151,6 +151,7 @@ function InnerInformationPanel(props: InnerInformationPanelProps) {
|
|
|
151
151
|
<Input2Controller
|
|
152
152
|
control={control}
|
|
153
153
|
name={`metaInfo.${row.index}.value`}
|
|
154
|
+
mapValue={String}
|
|
154
155
|
noShadowBox
|
|
155
156
|
/>
|
|
156
157
|
);
|
|
@@ -196,6 +197,7 @@ function InnerInformationPanel(props: InnerInformationPanelProps) {
|
|
|
196
197
|
);
|
|
197
198
|
|
|
198
199
|
const values = watch('metaInfo');
|
|
200
|
+
|
|
199
201
|
return (
|
|
200
202
|
<>
|
|
201
203
|
<StyledDialogBody>
|