nmrium 1.7.0 → 1.8.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.
Files changed (210) hide show
  1. package/lib/component/1d/ranges/Atoms.d.ts.map +1 -1
  2. package/lib/component/1d/ranges/Atoms.js +24 -9
  3. package/lib/component/1d/ranges/Atoms.js.map +1 -1
  4. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.d.ts +2 -1
  5. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.d.ts.map +1 -1
  6. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +32 -42
  7. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js.map +1 -1
  8. package/lib/component/1d-2d/components/FloatMoleculeStructures/FloatMolecules.d.ts.map +1 -1
  9. package/lib/component/1d-2d/components/FloatMoleculeStructures/FloatMolecules.js.map +1 -1
  10. package/lib/component/2d/zones/SignalsGuideLines.js +1 -1
  11. package/lib/component/2d/zones/SignalsGuideLines.js.map +1 -1
  12. package/lib/component/hooks/useExport.js +1 -1
  13. package/lib/component/hooks/useExport.js.map +1 -1
  14. package/lib/component/loader/useLoadFiles.d.ts.map +1 -1
  15. package/lib/component/loader/useLoadFiles.js +17 -7
  16. package/lib/component/loader/useLoadFiles.js.map +1 -1
  17. package/lib/component/main/NMRiumStateProvider.d.ts.map +1 -1
  18. package/lib/component/main/NMRiumStateProvider.js +2 -3
  19. package/lib/component/main/NMRiumStateProvider.js.map +1 -1
  20. package/lib/component/modal/LoadJCAMPModal.js +7 -2
  21. package/lib/component/modal/LoadJCAMPModal.js.map +1 -1
  22. package/lib/component/modal/MoleculeStructureEditorModal.d.ts.map +1 -1
  23. package/lib/component/modal/MoleculeStructureEditorModal.js +7 -3
  24. package/lib/component/modal/MoleculeStructureEditorModal.js.map +1 -1
  25. package/lib/component/modal/SaveAsModal.d.ts.map +1 -1
  26. package/lib/component/modal/SaveAsModal.js +6 -2
  27. package/lib/component/modal/SaveAsModal.js.map +1 -1
  28. package/lib/component/modal/setting/settings-tabs/ToolsTabContent.d.ts.map +1 -1
  29. package/lib/component/modal/setting/settings-tabs/ToolsTabContent.js +16 -0
  30. package/lib/component/modal/setting/settings-tabs/ToolsTabContent.js.map +1 -1
  31. package/lib/component/panels/MoleculesPanel/MoleculeOptionsPanel.d.ts +6 -0
  32. package/lib/component/panels/MoleculesPanel/MoleculeOptionsPanel.d.ts.map +1 -0
  33. package/lib/component/panels/MoleculesPanel/MoleculeOptionsPanel.js +87 -0
  34. package/lib/component/panels/MoleculesPanel/MoleculeOptionsPanel.js.map +1 -0
  35. package/lib/component/panels/MoleculesPanel/MoleculePanel.d.ts.map +1 -1
  36. package/lib/component/panels/MoleculesPanel/MoleculePanel.js +18 -26
  37. package/lib/component/panels/MoleculesPanel/MoleculePanel.js.map +1 -1
  38. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts.map +1 -1
  39. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +32 -25
  40. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js.map +1 -1
  41. package/lib/component/panels/MoleculesPanel/MoleculeStructure.d.ts +13 -0
  42. package/lib/component/panels/MoleculesPanel/MoleculeStructure.d.ts.map +1 -0
  43. package/lib/component/panels/MoleculesPanel/MoleculeStructure.js +66 -0
  44. package/lib/component/panels/MoleculesPanel/MoleculeStructure.js.map +1 -0
  45. package/lib/component/panels/MoleculesPanel/{useAtomAssignment.d.ts → hooks/useAtomAssignment.d.ts} +1 -1
  46. package/lib/component/panels/MoleculesPanel/hooks/useAtomAssignment.d.ts.map +1 -0
  47. package/lib/component/panels/MoleculesPanel/{useAtomAssignment.js → hooks/useAtomAssignment.js} +32 -16
  48. package/lib/component/panels/MoleculesPanel/hooks/useAtomAssignment.js.map +1 -0
  49. package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.d.ts +12 -0
  50. package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.d.ts.map +1 -0
  51. package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.js +58 -0
  52. package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.js.map +1 -0
  53. package/lib/component/panels/MoleculesPanel/utilities/AtomData.d.ts +5 -0
  54. package/lib/component/panels/MoleculesPanel/utilities/AtomData.d.ts.map +1 -0
  55. package/lib/component/panels/MoleculesPanel/utilities/AtomData.js +2 -0
  56. package/lib/component/panels/MoleculesPanel/utilities/AtomData.js.map +1 -0
  57. package/lib/component/panels/MoleculesPanel/utilities/extractFromAtom.d.ts +16 -0
  58. package/lib/component/panels/MoleculesPanel/utilities/extractFromAtom.d.ts.map +1 -0
  59. package/lib/component/panels/MoleculesPanel/utilities/extractFromAtom.js +47 -0
  60. package/lib/component/panels/MoleculesPanel/utilities/extractFromAtom.js.map +1 -0
  61. package/lib/component/panels/MoleculesPanel/utilities/getAssignIds.d.ts +18 -0
  62. package/lib/component/panels/MoleculesPanel/utilities/getAssignIds.d.ts.map +1 -0
  63. package/lib/component/panels/MoleculesPanel/utilities/getAssignIds.js +31 -0
  64. package/lib/component/panels/MoleculesPanel/utilities/getAssignIds.js.map +1 -0
  65. package/lib/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.d.ts +3 -0
  66. package/lib/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.d.ts.map +1 -0
  67. package/lib/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.js +12 -0
  68. package/lib/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.js.map +1 -0
  69. package/lib/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.d.ts +4 -0
  70. package/lib/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.d.ts.map +1 -0
  71. package/lib/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.js +25 -0
  72. package/lib/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.js.map +1 -0
  73. package/lib/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.d.ts +6 -0
  74. package/lib/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.d.ts.map +1 -0
  75. package/lib/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.js +18 -0
  76. package/lib/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.js.map +1 -0
  77. package/lib/component/panels/hooks/useMoleculeAnnotationCore.d.ts +9 -0
  78. package/lib/component/panels/hooks/useMoleculeAnnotationCore.d.ts.map +1 -0
  79. package/lib/component/panels/hooks/useMoleculeAnnotationCore.js +27 -0
  80. package/lib/component/panels/hooks/useMoleculeAnnotationCore.js.map +1 -0
  81. package/lib/component/reducer/IgnoreActions.d.ts.map +1 -1
  82. package/lib/component/reducer/IgnoreActions.js +2 -1
  83. package/lib/component/reducer/IgnoreActions.js.map +1 -1
  84. package/lib/component/reducer/Reducer.d.ts +11 -5
  85. package/lib/component/reducer/Reducer.d.ts.map +1 -1
  86. package/lib/component/reducer/Reducer.js +8 -3
  87. package/lib/component/reducer/Reducer.js.map +1 -1
  88. package/lib/component/reducer/actions/LoadAction.d.ts +7 -4
  89. package/lib/component/reducer/actions/LoadAction.d.ts.map +1 -1
  90. package/lib/component/reducer/actions/LoadAction.js +35 -26
  91. package/lib/component/reducer/actions/LoadAction.js.map +1 -1
  92. package/lib/component/reducer/actions/MoleculeActions.d.ts +20 -5
  93. package/lib/component/reducer/actions/MoleculeActions.d.ts.map +1 -1
  94. package/lib/component/reducer/actions/MoleculeActions.js +42 -28
  95. package/lib/component/reducer/actions/MoleculeActions.js.map +1 -1
  96. package/lib/component/reducer/actions/RangesActions.d.ts +10 -4
  97. package/lib/component/reducer/actions/RangesActions.d.ts.map +1 -1
  98. package/lib/component/reducer/actions/RangesActions.js +24 -3
  99. package/lib/component/reducer/actions/RangesActions.js.map +1 -1
  100. package/lib/component/reducer/actions/ZonesActions.d.ts +1 -1
  101. package/lib/component/reducer/actions/ZonesActions.d.ts.map +1 -1
  102. package/lib/component/reducer/preferences/actions/changeDefaultMoleculeSettings.d.ts +4 -0
  103. package/lib/component/reducer/preferences/actions/changeDefaultMoleculeSettings.d.ts.map +1 -0
  104. package/lib/component/reducer/preferences/actions/changeDefaultMoleculeSettings.js +7 -0
  105. package/lib/component/reducer/preferences/actions/changeDefaultMoleculeSettings.js.map +1 -0
  106. package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -2
  107. package/lib/component/reducer/preferences/preferencesReducer.d.ts.map +1 -1
  108. package/lib/component/reducer/preferences/preferencesReducer.js +3 -0
  109. package/lib/component/reducer/preferences/preferencesReducer.js.map +1 -1
  110. package/lib/component/toolbar/ToolTypes.d.ts.map +1 -1
  111. package/lib/component/toolbar/ToolTypes.js +1 -0
  112. package/lib/component/toolbar/ToolTypes.js.map +1 -1
  113. package/lib/component/workspaces/assignment.d.ts.map +1 -1
  114. package/lib/component/workspaces/assignment.js +7 -0
  115. package/lib/component/workspaces/assignment.js.map +1 -1
  116. package/lib/component/workspaces/basic.d.ts.map +1 -1
  117. package/lib/component/workspaces/basic.js +5 -0
  118. package/lib/component/workspaces/basic.js.map +1 -1
  119. package/lib/component/workspaces/embedded.d.ts.map +1 -1
  120. package/lib/component/workspaces/embedded.js +5 -0
  121. package/lib/component/workspaces/embedded.js.map +1 -1
  122. package/lib/component/workspaces/exercise.d.ts.map +1 -1
  123. package/lib/component/workspaces/exercise.js +5 -0
  124. package/lib/component/workspaces/exercise.js.map +1 -1
  125. package/lib/component/workspaces/prediction.d.ts.map +1 -1
  126. package/lib/component/workspaces/prediction.js +5 -0
  127. package/lib/component/workspaces/prediction.js.map +1 -1
  128. package/lib/component/workspaces/process1D.d.ts.map +1 -1
  129. package/lib/component/workspaces/process1D.js +6 -0
  130. package/lib/component/workspaces/process1D.js.map +1 -1
  131. package/lib/component/workspaces/workspaceDefaultProperties.d.ts.map +1 -1
  132. package/lib/component/workspaces/workspaceDefaultProperties.js +18 -0
  133. package/lib/component/workspaces/workspaceDefaultProperties.js.map +1 -1
  134. package/lib/data/SpectraManager.d.ts +1 -1
  135. package/lib/data/SpectraManager.d.ts.map +1 -1
  136. package/lib/data/SpectraManager.js.map +1 -1
  137. package/lib/data/data1d/Spectrum1D/initiateDatum1D.d.ts +0 -1
  138. package/lib/data/data1d/Spectrum1D/initiateDatum1D.d.ts.map +1 -1
  139. package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +17 -16
  140. package/lib/data/data1d/Spectrum1D/initiateDatum1D.js.map +1 -1
  141. package/lib/data/data2d/Spectrum2D/initiateDatum2D.d.ts +0 -1
  142. package/lib/data/data2d/Spectrum2D/initiateDatum2D.d.ts.map +1 -1
  143. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +7 -6
  144. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js.map +1 -1
  145. package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts.map +1 -1
  146. package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts.map +1 -1
  147. package/lib/data/molecules/Molecule.d.ts +1 -17
  148. package/lib/data/molecules/Molecule.d.ts.map +1 -1
  149. package/lib/data/molecules/Molecule.js +3 -7
  150. package/lib/data/molecules/Molecule.js.map +1 -1
  151. package/lib/data/molecules/MoleculeManager.d.ts +1 -1
  152. package/lib/data/molecules/MoleculeManager.d.ts.map +1 -1
  153. package/lib/data/molecules/MoleculeManager.js +1 -4
  154. package/lib/data/molecules/MoleculeManager.js.map +1 -1
  155. package/lib/versionInfo.js +1 -1
  156. package/package.json +27 -27
  157. package/src/component/1d/ranges/Atoms.tsx +36 -13
  158. package/src/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.tsx +38 -79
  159. package/src/component/1d-2d/components/FloatMoleculeStructures/FloatMolecules.tsx +5 -2
  160. package/src/component/2d/zones/SignalsGuideLines.tsx +1 -1
  161. package/src/component/hooks/useExport.tsx +1 -1
  162. package/src/component/loader/useLoadFiles.ts +19 -7
  163. package/src/component/main/NMRiumStateProvider.tsx +2 -3
  164. package/src/component/modal/LoadJCAMPModal.tsx +10 -4
  165. package/src/component/modal/MoleculeStructureEditorModal.tsx +10 -3
  166. package/src/component/modal/SaveAsModal.tsx +8 -2
  167. package/src/component/modal/setting/settings-tabs/ToolsTabContent.tsx +16 -0
  168. package/src/component/panels/MoleculesPanel/MoleculeOptionsPanel.tsx +160 -0
  169. package/src/component/panels/MoleculesPanel/MoleculePanel.tsx +77 -101
  170. package/src/component/panels/MoleculesPanel/MoleculePanelHeader.tsx +54 -35
  171. package/src/component/panels/MoleculesPanel/MoleculeStructure.tsx +117 -0
  172. package/src/component/panels/MoleculesPanel/{useAtomAssignment.tsx → hooks/useAtomAssignment.tsx} +47 -25
  173. package/src/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.ts +74 -0
  174. package/src/component/panels/MoleculesPanel/utilities/AtomData.ts +4 -0
  175. package/src/component/panels/MoleculesPanel/utilities/extractFromAtom.ts +63 -0
  176. package/src/component/panels/MoleculesPanel/utilities/getAssignIds.ts +59 -0
  177. package/src/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.ts +12 -0
  178. package/src/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.ts +36 -0
  179. package/src/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.ts +20 -0
  180. package/src/component/panels/hooks/useMoleculeAnnotationCore.ts +36 -0
  181. package/src/component/reducer/IgnoreActions.ts +2 -1
  182. package/src/component/reducer/Reducer.ts +21 -8
  183. package/src/component/reducer/actions/LoadAction.ts +51 -38
  184. package/src/component/reducer/actions/MoleculeActions.ts +85 -37
  185. package/src/component/reducer/actions/RangesActions.ts +50 -5
  186. package/src/component/reducer/actions/ZonesActions.ts +1 -1
  187. package/src/component/reducer/preferences/actions/changeDefaultMoleculeSettings.ts +16 -0
  188. package/src/component/reducer/preferences/preferencesReducer.ts +11 -1
  189. package/src/component/toolbar/ToolTypes.ts +1 -0
  190. package/src/component/workspaces/assignment.ts +7 -0
  191. package/src/component/workspaces/basic.ts +5 -0
  192. package/src/component/workspaces/embedded.ts +5 -0
  193. package/src/component/workspaces/exercise.ts +5 -0
  194. package/src/component/workspaces/prediction.ts +5 -0
  195. package/src/component/workspaces/process1D.ts +6 -0
  196. package/src/component/workspaces/workspaceDefaultProperties.ts +18 -0
  197. package/src/data/SpectraManager.ts +1 -7
  198. package/src/data/data1d/Spectrum1D/initiateDatum1D.ts +17 -19
  199. package/src/data/data2d/Spectrum2D/initiateDatum2D.ts +7 -10
  200. package/src/data/molecules/Molecule.ts +5 -25
  201. package/src/data/molecules/MoleculeManager.ts +0 -4
  202. package/src/index.tsx +0 -3
  203. package/src/versionInfo.ts +1 -1
  204. package/lib/component/panels/MoleculesPanel/Utilities.d.ts +0 -43
  205. package/lib/component/panels/MoleculesPanel/Utilities.d.ts.map +0 -1
  206. package/lib/component/panels/MoleculesPanel/Utilities.js +0 -129
  207. package/lib/component/panels/MoleculesPanel/Utilities.js.map +0 -1
  208. package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts.map +0 -1
  209. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js.map +0 -1
  210. package/src/component/panels/MoleculesPanel/Utilities.ts +0 -188
@@ -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
- { molecules: StateMolecule[] }
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' | 'TOGGLE_MOLECULE_ATOM_NUMBER',
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 (floatMoleculeOnSave && lastAddedMolecule) {
98
- floatMoleculeOverSpectrum(draft, lastAddedMolecule.id, true);
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.molecules;
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(id: string, draft: Draft<State>) {
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: false,
348
+ visible: isMoleculeFloating ?? visible,
349
+ ...other,
308
350
  bounding: {
309
- ...DRAGGABLE_STRUCTURE_INITIAL_BOUNDING_REACT,
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
- floatMoleculeOverSpectrum(draft, id);
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 handleToggleMoleculeAtomsNumbers(
407
+ function handleChangeMoleculeAnnotation(
375
408
  draft: Draft<State>,
376
- action: ToggleMoleculeViewObjectAction,
409
+ action: ChangeMoleculeAnnotationAction,
377
410
  ) {
378
- const { id } = action.payload;
411
+ const { id, atomAnnotation } = action.payload;
379
412
 
380
- initMoleculeViewProperties(id, draft);
413
+ initMoleculeViewProperties(draft, { id });
381
414
  const molecule = getMoleculeViewObject(id, draft);
382
- if (molecule) {
383
- molecule.showAtomNumber = !molecule.showAtomNumber;
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
- handleToggleMoleculeAtomsNumbers,
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/Utilities.js';
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/Utilities.js';
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
+ }
@@ -3,6 +3,7 @@ import type {
3
3
  CustomWorkspaces,
4
4
  ExportPreferences,
5
5
  ExportSettings,
6
+ MoleculeView,
6
7
  MultipleSpectraAnalysisPreferences,
7
8
  NMRiumPanelPreferences,
8
9
  PanelPreferencesType,
@@ -30,6 +31,7 @@ import {
30
31
  setSpectraAnalysisPanelsPreferences,
31
32
  } from './actions/analyzeSpectra.js';
32
33
  import { applyGeneralPreferences } from './actions/applyGeneralPreferences.js';
34
+ import { changeDefaultMoleculeSettings } from './actions/changeDefaultMoleculeSettings.ts';
33
35
  import { changeExportAcsSettings } from './actions/changeExportAcsSettings.ts';
34
36
  import { changeExportSettings } from './actions/changeExportSettings.js';
35
37
  import { changeInformationBlockPosition } from './actions/changeInformationBlockPosition.js';
@@ -170,6 +172,11 @@ export type TogglePanelAction = ActionType<
170
172
  }
171
173
  >;
172
174
 
175
+ export type ChangeDefaultMoleculeSettingsAction = ActionType<
176
+ 'CHANGE_DEFAULT_MOLECULE_SETTINGS',
177
+ MoleculeView
178
+ >;
179
+
173
180
  export type PreferencesActions =
174
181
  | InitPreferencesAction
175
182
  | SetPreferencesAction
@@ -190,7 +197,8 @@ export type PreferencesActions =
190
197
  | ChangeExportSettingsAction
191
198
  | ChangePeaksLabelPositionAction
192
199
  | TogglePanelAction
193
- | ChangeExportACSSettingsAction;
200
+ | ChangeExportACSSettingsAction
201
+ | ChangeDefaultMoleculeSettingsAction;
194
202
 
195
203
  export type WorkspaceWithSource = Workspace & { source: WorkSpaceSource };
196
204
  type WorkspacesWithSource = Record<string, WorkspaceWithSource>;
@@ -314,6 +322,8 @@ function innerPreferencesReducer(
314
322
  return togglePanel(draft, action);
315
323
  case 'CHANGE_EXPORT_ACS_SETTINGS':
316
324
  return changeExportAcsSettings(draft, action);
325
+ case 'CHANGE_DEFAULT_MOLECULE_SETTINGS':
326
+ return changeDefaultMoleculeSettings(draft, action);
317
327
 
318
328
  default:
319
329
  return draft;
@@ -357,6 +357,7 @@ export const options: RecordOptions = {
357
357
  mode: '2D',
358
358
  spectraOptions: [
359
359
  {
360
+ info: [{ key: 'isFt', value: true }],
360
361
  active: true,
361
362
  },
362
363
  ],
@@ -29,6 +29,13 @@ export const assignment: InnerWorkspace = {
29
29
  phaseCorrection: true,
30
30
  baselineCorrection: true,
31
31
  autoRangeAndZonePicking: true,
32
+ fftDimension1: true,
33
+ fftDimension2: true,
34
+ apodizationDimension1: true,
35
+ apodizationDimension2: true,
36
+ phaseCorrectionTwoDimensions: true,
37
+ zeroFillingDimension1: true,
38
+ zeroFillingDimension2: true,
32
39
  inset: true,
33
40
  },
34
41
  },
@@ -35,6 +35,11 @@ export const basic: InnerWorkspace = {
35
35
  autoRangeAndZonePicking: true,
36
36
  fftDimension1: true,
37
37
  fftDimension2: true,
38
+ apodizationDimension1: true,
39
+ apodizationDimension2: true,
40
+ phaseCorrectionTwoDimensions: true,
41
+ zeroFillingDimension1: true,
42
+ zeroFillingDimension2: true,
38
43
  inset: true,
39
44
  },
40
45
  },
@@ -46,6 +46,11 @@ export const embedded: InnerWorkspace = {
46
46
  autoRangeAndZonePicking: true,
47
47
  fftDimension1: true,
48
48
  fftDimension2: true,
49
+ apodizationDimension1: true,
50
+ apodizationDimension2: true,
51
+ phaseCorrectionTwoDimensions: true,
52
+ zeroFillingDimension1: true,
53
+ zeroFillingDimension2: true,
49
54
  inset: true,
50
55
  },
51
56
  },
@@ -26,6 +26,11 @@ export const exercise: InnerWorkspace = {
26
26
  spectraStackAlignments: true,
27
27
  fftDimension1: true,
28
28
  fftDimension2: true,
29
+ apodizationDimension1: true,
30
+ apodizationDimension2: true,
31
+ phaseCorrectionTwoDimensions: true,
32
+ zeroFillingDimension1: true,
33
+ zeroFillingDimension2: true,
29
34
  inset: true,
30
35
  },
31
36
  },
@@ -46,6 +46,11 @@ export const prediction: InnerWorkspace = {
46
46
  autoRangeAndZonePicking: true,
47
47
  fftDimension1: true,
48
48
  fftDimension2: true,
49
+ apodizationDimension1: true,
50
+ apodizationDimension2: true,
51
+ phaseCorrectionTwoDimensions: true,
52
+ zeroFillingDimension1: true,
53
+ zeroFillingDimension2: true,
49
54
  inset: true,
50
55
  },
51
56
  },
@@ -23,9 +23,15 @@ export const process1D: InnerWorkspace = {
23
23
  spectraCenterAlignments: true,
24
24
  peakPicking: true,
25
25
  apodization: true,
26
+ apodizationDimension1: true,
27
+ apodizationDimension2: true,
26
28
  zeroFilling: true,
29
+ zeroFillingDimension1: true,
30
+ zeroFillingDimension2: true,
31
+ zonePicking: true,
27
32
  fft: true,
28
33
  phaseCorrection: true,
34
+ phaseCorrectionTwoDimensions: true,
29
35
  baselineCorrection: true,
30
36
  exclusionZones: true,
31
37
  multipleSpectraAnalysis: true,
@@ -60,6 +60,11 @@ export const workspaceDefaultProperties: Required<WorkspacePreferences> = {
60
60
  fftDimension1: false,
61
61
  fftDimension2: false,
62
62
  inset: false,
63
+ apodizationDimension1: false,
64
+ apodizationDimension2: false,
65
+ zeroFillingDimension1: false,
66
+ zeroFillingDimension2: false,
67
+ phaseCorrectionTwoDimensions: false,
63
68
  },
64
69
  },
65
70
 
@@ -271,4 +276,17 @@ export const workspaceDefaultProperties: Required<WorkspacePreferences> = {
271
276
  deltaFormat: '0.00',
272
277
  },
273
278
  },
279
+ defaultMoleculeSettings: {
280
+ showLabel: false,
281
+ atomAnnotation: 'custom-labels',
282
+ floating: {
283
+ visible: true,
284
+ bounding: {
285
+ x: 10,
286
+ y: 10,
287
+ width: 130,
288
+ height: 120,
289
+ },
290
+ },
291
+ },
274
292
  };
@@ -129,13 +129,7 @@ export function toJSON(
129
129
  core: NMRiumCore,
130
130
  state: Pick<
131
131
  State,
132
- | 'data'
133
- | 'sources'
134
- | 'molecules'
135
- | 'correlations'
136
- | 'actionType'
137
- | 'view'
138
- | 'fileCollections'
132
+ 'data' | 'sources' | 'molecules' | 'correlations' | 'actionType' | 'view'
139
133
  >,
140
134
  preferencesState: {
141
135
  current: Workspace;
@@ -19,33 +19,31 @@ interface InitiateDatum1DOptions {
19
19
  usedColors?: UsedColors;
20
20
  molecules?: StateMoleculeExtended[];
21
21
  colors?: SpectrumOneDimensionColor[];
22
- fileCollectionId?: string | undefined;
23
22
  }
24
23
 
25
24
  export function initiateDatum1D(
26
25
  spectrum: any,
27
26
  options: InitiateDatum1DOptions = {},
28
27
  ): Spectrum1D {
29
- const { usedColors, colors, molecules = [], fileCollectionId } = options;
28
+ const { usedColors, colors, molecules = [] } = options;
30
29
 
31
30
  const { integrals, ranges, ...restSpectrum } = spectrum;
32
- const spectrumObj: Spectrum1D = { ...restSpectrum };
33
- spectrumObj.id = spectrum.id || crypto.randomUUID();
34
- spectrumObj.fileCollectionId = spectrum.fileCollectionId || fileCollectionId;
35
-
36
- spectrumObj.display = {
37
- isVisible: true,
38
- isRealSpectrumVisible: true,
39
- ...spectrum.display,
40
- ...get1DColor(spectrum, { usedColors, colors }),
41
- };
42
-
43
- spectrumObj.info = {
44
- nucleus: '1H', // 1H, 13C, 19F, ...
45
- isFid: false,
46
- isComplex: false, // if isComplex is true that mean it contains real/ imaginary x set, if not hid re/im button .
47
- dimension: 1,
48
- ...spectrum.info,
31
+ const spectrumObj: Spectrum1D = {
32
+ ...restSpectrum,
33
+ id: spectrum.id || crypto.randomUUID(),
34
+ display: {
35
+ isVisible: true,
36
+ isRealSpectrumVisible: true,
37
+ ...spectrum.display,
38
+ ...get1DColor(spectrum, { usedColors, colors }),
39
+ },
40
+ info: {
41
+ nucleus: '1H', // 1H, 13C, 19F, ...
42
+ isFid: false,
43
+ isComplex: false, // if isComplex is true that mean it contains real/ imaginary x set, if not hid re/im button .
44
+ dimension: 1,
45
+ ...spectrum.info,
46
+ },
49
47
  };
50
48
 
51
49
  spectrumObj.originalInfo = spectrumObj.info;
@@ -19,7 +19,6 @@ const defaultMinMax = { z: [], minX: 0, minY: 0, maxX: 0, maxY: 0 };
19
19
  interface InitiateDatum2DOptions {
20
20
  usedColors?: UsedColors;
21
21
  colors?: SpectrumTwoDimensionsColor[];
22
- fileCollectionId?: string;
23
22
  }
24
23
 
25
24
  function initiateDisplay(spectrum: any, options: InitiateDatum2DOptions) {
@@ -60,15 +59,13 @@ export function initiateDatum2D(
60
59
  spectrum: any,
61
60
  options: InitiateDatum2DOptions = {},
62
61
  ): Spectrum2D {
63
- const { usedColors, colors, fileCollectionId } = options;
64
- const datum: any = { ...spectrum };
65
-
66
- datum.id = spectrum.id || crypto.randomUUID();
67
- datum.fileCollectionId = spectrum.fileCollectionId || fileCollectionId;
68
-
69
- datum.display = initiateDisplay(spectrum, { usedColors, colors });
70
-
71
- datum.info = initiateInfo(spectrum);
62
+ const { usedColors, colors } = options;
63
+ const datum: any = {
64
+ ...spectrum,
65
+ id: spectrum.id || crypto.randomUUID(),
66
+ display: initiateDisplay(spectrum, { usedColors, colors }),
67
+ info: initiateInfo(spectrum),
68
+ };
72
69
 
73
70
  datum.originalInfo = datum.info;
74
71