nmrium 0.48.0 → 0.50.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 (154) hide show
  1. package/lib/component/1d/Chart1D.js +3 -1
  2. package/lib/component/1d/LinesSeries.js +1 -1
  3. package/lib/component/1d/SimilarityTree.d.ts +1 -0
  4. package/lib/component/1d/SimilarityTree.js +60 -0
  5. package/lib/component/1d/SpectraLegends.js +1 -1
  6. package/lib/component/1d/Viewer1D.js +142 -124
  7. package/lib/component/1d/jCouplingGraph/JsCoupling.js +1 -1
  8. package/lib/component/1d/multiplicityTree/MultiplicityTree.d.ts +1 -7
  9. package/lib/component/1d/multiplicityTree/MultiplicityTree.js +114 -125
  10. package/lib/component/1d/multiplicityTree/MultiplicityTrees.d.ts +1 -0
  11. package/lib/component/1d/multiplicityTree/MultiplicityTrees.js +23 -0
  12. package/lib/component/1d/multiplicityTree/generateTreeNodes.d.ts +18 -0
  13. package/lib/component/1d/multiplicityTree/generateTreeNodes.js +66 -0
  14. package/lib/component/1d/ranges/Atoms.d.ts +7 -0
  15. package/lib/component/1d/ranges/Atoms.js +43 -0
  16. package/lib/component/1d/ranges/Range.d.ts +1 -1
  17. package/lib/component/1d/ranges/Range.js +10 -9
  18. package/lib/component/1d/tool/BaseLine.d.ts +2 -0
  19. package/lib/component/1d/tool/BaseLine.js +26 -0
  20. package/lib/component/1d/tool/BaseLineZones.js +18 -3
  21. package/lib/component/2d/Chart2D.js +6 -4
  22. package/lib/component/2d/Viewer2D.js +35 -26
  23. package/lib/component/context/KeyModifierContext.d.ts +13 -2
  24. package/lib/component/context/KeyModifierContext.js +35 -4
  25. package/lib/component/context/LoggerContext.d.ts +9 -0
  26. package/lib/component/context/LoggerContext.js +21 -7
  27. package/lib/component/context/PreferencesContext.d.ts +1 -108
  28. package/lib/component/context/TopicMoleculeContext.d.ts +8 -0
  29. package/lib/component/context/TopicMoleculeContext.js +30 -0
  30. package/lib/component/elements/CloseButton.d.ts +2 -10
  31. package/lib/component/elements/CloseButton.js +3 -20
  32. package/lib/component/elements/CounterLabel.js +0 -1
  33. package/lib/component/elements/DeleteButton.d.ts +5 -7
  34. package/lib/component/elements/DeleteButton.js +7 -5
  35. package/lib/component/elements/FilterButton.d.ts +6 -0
  36. package/lib/component/elements/FilterButton.js +8 -0
  37. package/lib/component/elements/Input.js +4 -1
  38. package/lib/component/elements/PreferencesButton.d.ts +2 -4
  39. package/lib/component/elements/PreferencesButton.js +5 -3
  40. package/lib/component/elements/ReactTable/ReactTable.js +5 -2
  41. package/lib/component/elements/ResizerWithScale.js +19 -2
  42. package/lib/component/elements/SVGGroup.js +2 -2
  43. package/lib/component/elements/SaveButton.d.ts +2 -11
  44. package/lib/component/elements/SaveButton.js +4 -19
  45. package/lib/component/elements/ToolBarButton.d.ts +9 -0
  46. package/lib/component/elements/ToolBarButton.js +14 -0
  47. package/lib/component/elements/formik/FormikTextarea.js +8 -9
  48. package/lib/component/elements/linearAxis/LinearVerticalAxis.js +1 -1
  49. package/lib/component/elements/popup/Modal/ConfirmDialog.d.ts +2 -1
  50. package/lib/component/elements/popup/Modal/ConfirmDialog.js +11 -8
  51. package/lib/component/elements/resizer/SVGResizer.js +1 -1
  52. package/lib/component/header/BaseLineCorrectionPanel.js +3 -2
  53. package/lib/component/header/Header.js +2 -2
  54. package/lib/component/hooks/useCheckToolsVisibility.js +1 -1
  55. package/lib/component/hooks/useSaveSettings.js +3 -2
  56. package/lib/component/hooks/useToolsFunctions.js +4 -2
  57. package/lib/component/main/InnerNMRium.js +2 -1
  58. package/lib/component/main/InnerNMRiumContents.js +1 -1
  59. package/lib/component/modal/AboutPredictionModal.js +4 -8
  60. package/lib/component/modal/AboutSpectrumSimulationModal.js +4 -8
  61. package/lib/component/modal/CopyClipboardModal.js +1 -1
  62. package/lib/component/modal/EditPeakShapeModal.js +2 -2
  63. package/lib/component/modal/ExportAsJcampModal.d.ts +1 -1
  64. package/lib/component/modal/ExportAsJcampModal.js +8 -4
  65. package/lib/component/modal/ImportPublicationStringModal.d.ts +2 -1
  66. package/lib/component/modal/ImportPublicationStringModal.js +80 -32
  67. package/lib/component/modal/LoadJCAMPModal.js +12 -9
  68. package/lib/component/modal/LogsHistoryModal.d.ts +1 -1
  69. package/lib/component/modal/LogsHistoryModal.js +9 -4
  70. package/lib/component/modal/MoleculeStructureEditorModal.js +10 -3
  71. package/lib/component/modal/MultipletAnalysisModal.js +8 -8
  72. package/lib/component/modal/PredictSpectraModal.js +6 -5
  73. package/lib/component/modal/SaveAsModal.js +2 -2
  74. package/lib/component/modal/aboutUs/AboutUsModal.js +11 -26
  75. package/lib/component/modal/changeSum/ChangeSumModal.d.ts +4 -3
  76. package/lib/component/modal/changeSum/ChangeSumModal.js +10 -3
  77. package/lib/component/modal/changeSum/ChangeSumModalContents.d.ts +1 -3
  78. package/lib/component/modal/changeSum/ChangeSumModalContents.js +9 -6
  79. package/lib/component/modal/editRange/EditRangeModal.js +8 -6
  80. package/lib/component/modal/editRange/forms/components/AddSignalFormTab.js +1 -0
  81. package/lib/component/modal/editRange/forms/components/CouplingsTable.js +13 -10
  82. package/lib/component/modal/editRange/forms/components/SignalFormTab.js +1 -1
  83. package/lib/component/modal/editRange/forms/components/SignalsForm.js +1 -0
  84. package/lib/component/modal/editZone/EditZoneModal.js +3 -3
  85. package/lib/component/modal/metaImportation/MetaImportationModal.js +1 -1
  86. package/lib/component/modal/setting/GeneralSettings.js +17 -38
  87. package/lib/component/modal/setting/settings-tabs/GeneralTabContent.js +9 -11
  88. package/lib/component/modal/setting/settings-tabs/OnLoadProcessingTabContent.js +2 -4
  89. package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +2 -2
  90. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +6 -23
  91. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +3 -3
  92. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -4
  93. package/lib/component/panels/PeaksPanel/PeaksPanel.js +7 -8
  94. package/lib/component/panels/PeaksPanel/PeaksToggleActions.d.ts +8 -6
  95. package/lib/component/panels/PeaksPanel/PeaksToggleActions.js +3 -6
  96. package/lib/component/panels/RangesPanel/RangesHeader.d.ts +1 -1
  97. package/lib/component/panels/RangesPanel/RangesHeader.js +8 -31
  98. package/lib/component/panels/RangesPanel/RangesTable.js +1 -1
  99. package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +2 -2
  100. package/lib/component/panels/SpectrumsPanel/SpectraPreferences.js +39 -5
  101. package/lib/component/panels/SpectrumsPanel/SpectraTable.js +42 -11
  102. package/lib/component/panels/SpectrumsPanel/SpectrumListPanel.js +4 -2
  103. package/lib/component/panels/SpectrumsPanel/base/SpectraColumnsManager.js +19 -16
  104. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +1 -1
  105. package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.js +1 -1
  106. package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.js +1 -1
  107. package/lib/component/panels/SummaryPanel/SummaryPanel.js +4 -3
  108. package/lib/component/panels/ZonesPanel/ZonesPanel.js +2 -26
  109. package/lib/component/panels/databasePanel/DatabasePanel.js +6 -6
  110. package/lib/component/panels/databasePanel/DatabaseSearchOptions.d.ts +4 -6
  111. package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +12 -13
  112. package/lib/component/panels/databasePanel/DatabaseStructureSearchModal.js +7 -8
  113. package/lib/component/panels/filtersPanel/FiltersTable.js +1 -1
  114. package/lib/component/panels/header/DefaultPanelHeader.js +9 -4
  115. package/lib/component/panels/header/PanelHeader.js +0 -1
  116. package/lib/component/panels/header/PreferencesHeader.d.ts +2 -4
  117. package/lib/component/panels/header/PreferencesHeader.js +9 -23
  118. package/lib/component/panels/header/SpectraAutomaticPickingButton.js +2 -2
  119. package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -9
  120. package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +3 -3
  121. package/lib/component/reducer/Reducer.js +5 -0
  122. package/lib/component/reducer/actions/DatabaseActions.d.ts +3 -2
  123. package/lib/component/reducer/actions/DatabaseActions.js +5 -1
  124. package/lib/component/reducer/actions/FiltersActions.d.ts +3 -4
  125. package/lib/component/reducer/actions/FiltersActions.js +92 -55
  126. package/lib/component/reducer/actions/LoadActions.js +10 -8
  127. package/lib/component/reducer/actions/SpectrumsActions.d.ts +8 -1
  128. package/lib/component/reducer/actions/SpectrumsActions.js +3 -3
  129. package/lib/component/reducer/actions/ToolsActions.d.ts +8 -5
  130. package/lib/component/reducer/actions/ToolsActions.js +51 -44
  131. package/lib/component/toolbar/BasicToolBar.js +11 -29
  132. package/lib/component/utility/export.js +3 -0
  133. package/lib/component/workspaces/exercise.js +1 -0
  134. package/lib/component/workspaces/prediction.js +1 -16
  135. package/lib/component/workspaces/simulation.js +1 -2
  136. package/lib/component/workspaces/workspaceDefaultProperties.js +4 -3
  137. package/lib/data/data1d/Spectrum1D/index.d.ts +0 -1
  138. package/lib/data/data1d/Spectrum1D/index.js +0 -1
  139. package/lib/utils/clipboard/clipboardComponents.d.ts +2 -2
  140. package/lib/utils/clipboard/clipboardComponents.js +8 -3
  141. package/lib/versionInfo.js +1 -1
  142. package/package.json +25 -23
  143. package/lib/component/1d/multiplicityTree/LevelNode.d.ts +0 -8
  144. package/lib/component/1d/multiplicityTree/LevelNode.js +0 -8
  145. package/lib/component/1d/multiplicityTree/StringNode.d.ts +0 -11
  146. package/lib/component/1d/multiplicityTree/StringNode.js +0 -7
  147. package/lib/component/1d/multiplicityTree/TreeColors.d.ts +0 -1
  148. package/lib/component/1d/multiplicityTree/TreeColors.js +0 -1
  149. package/lib/component/1d/multiplicityTree/TreeNodes.d.ts +0 -21
  150. package/lib/component/1d/multiplicityTree/TreeNodes.js +0 -23
  151. package/lib/component/1d/multiplicityTree/buildTreeNode.d.ts +0 -11
  152. package/lib/component/1d/multiplicityTree/buildTreeNode.js +0 -57
  153. package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.d.ts +0 -2
  154. package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.js +0 -6
@@ -4,12 +4,14 @@ import { usePreferences } from '../context/PreferencesContext';
4
4
  import ApodizationLine from './ApodizationLine';
5
5
  import ExclusionZonesAnnotations from './ExclusionZonesAnnotations';
6
6
  import LinesSeries from './LinesSeries';
7
+ import SimilarityTree from './SimilarityTree';
7
8
  import SpectraTracker from './SpectraLegends';
8
9
  import XAxis from './XAxis';
9
10
  import DatabaseElements from './database/DatabaseElements';
10
11
  import IntegralsSeries from './integral/IntegralsSeries';
11
12
  import JGraph from './jCouplingGraph/JGraph';
12
13
  import MultiAnalysisRanges from './multiAnalysis/MultiAnalysisRanges';
14
+ import MultiplicityTrees from './multiplicityTree/MultiplicityTrees';
13
15
  import { PeakEditionProvider } from './peaks/PeakEditionManager';
14
16
  import Peaks from './peaks/Peaks';
15
17
  import PeaksShapes from './peaks/PeaksShapes';
@@ -20,6 +22,6 @@ function Chart1D({ mode, width, height, margin, displayerKey }) {
20
22
  const { current: { general: { spectraRendering }, }, } = usePreferences();
21
23
  const innerWidth = width - margin.left - margin.right;
22
24
  const innerHeight = height - margin.bottom;
23
- return (_jsx(PeakEditionProvider, { children: _jsxs("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, id: "nmrSVG", shapeRendering: spectraRendering, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-chart-1d`, children: _jsx("rect", { width: innerWidth, height: innerHeight, x: margin.left, y: "0" }) }) }), _jsx(LinesSeries, {}), _jsx(ApodizationLine, {}), _jsx(IntegralsSeries, {}), _jsx(Peaks, { peaksSource: "peaks" }), _jsx(RangesIntegrals, {}), _jsx(Ranges, {}), _jsx(Peaks, { peaksSource: "ranges" }), _jsx(JGraph, {}), _jsx(MultiAnalysisRanges, {}), _jsx(BaseLineZones, {}), _jsx(ExclusionZonesAnnotations, {}), _jsx(DatabaseElements, {}), _jsx(PeaksShapes, {}), _jsx(SpectraTracker, {}), _jsx(SpectrumInfoBlock, {}), _jsx("g", { className: "container", style: { pointerEvents: 'none' }, children: _jsx(XAxis, { showGrid: true, mode: mode }) })] }) }));
25
+ return (_jsx(PeakEditionProvider, { children: _jsxs("svg", { id: "nmrSVG", width: width, height: height, viewBox: `0 0 ${width} ${height}`, fontFamily: "Arial, Helvetica, sans-serif", shapeRendering: spectraRendering, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-chart-1d`, children: _jsx("rect", { width: innerWidth, height: innerHeight, x: margin.left, y: "0" }) }) }), _jsx(LinesSeries, {}), _jsx(ApodizationLine, {}), _jsx(IntegralsSeries, {}), _jsx(Peaks, { peaksSource: "peaks" }), _jsx(RangesIntegrals, {}), _jsx(Peaks, { peaksSource: "ranges" }), _jsx(Ranges, {}), _jsx(MultiplicityTrees, {}), _jsx(JGraph, {}), _jsx(MultiAnalysisRanges, {}), _jsx(BaseLineZones, {}), _jsx(ExclusionZonesAnnotations, {}), _jsx(DatabaseElements, {}), _jsx(PeaksShapes, {}), _jsx(SpectraTracker, {}), _jsx(SpectrumInfoBlock, {}), _jsx(SimilarityTree, {}), _jsx("g", { className: "container", style: { pointerEvents: 'none' }, children: _jsx(XAxis, { showGrid: true, mode: mode }) })] }) }));
24
26
  }
25
27
  export default Chart1D;
@@ -29,6 +29,6 @@ function LinesSeries() {
29
29
  const { setActiveSpectrum } = useSetActiveSpectrumAction();
30
30
  return (_jsxs("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, className: "spectrums", children: [spectra.map((d, i) => (_jsxs("g", { children: [_jsx(Line, { display: d.display, id: d.id, data: get1DDataXY(d), index: i }), verticalAlign === 'stack' && (_jsx("rect", { css: style, y: innerHeight - shiftY * i - BOX_SIZE / 2, x: margin.left, width: `${innerWidth}px`, height: `${BOX_SIZE}px`, onClick: (e) => {
31
31
  setActiveSpectrum(e, d.id);
32
- } }))] }, d.id))), activeSpectra?.map((activeSpectrum) => (_jsx("use", { href: `#${activeSpectrum.id}` }, activeSpectrum.id)))] }));
32
+ }, "data-no-export": "true" }))] }, d.id))), activeSpectra?.map((activeSpectrum) => (_jsx("use", { href: `#${activeSpectrum.id}` }, activeSpectrum.id)))] }));
33
33
  }
34
34
  export default LinesSeries;
@@ -0,0 +1 @@
1
+ export default function SimilarityTree(): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,60 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createTree } from 'ml-tree-similarity';
3
+ import { Fragment } from 'react';
4
+ import { isSpectrum1D } from '../../data/data1d/Spectrum1D';
5
+ import { useChartData } from '../context/ChartContext';
6
+ import { useScaleChecked } from '../context/ScaleContext';
7
+ import { useFormatNumberByNucleus } from '../hooks/useFormatNumberByNucleus';
8
+ import useSpectrum from '../hooks/useSpectrum';
9
+ const circleSize = 3;
10
+ const marginTop = circleSize + 10;
11
+ const lineColor = 'black';
12
+ const textColor = 'black';
13
+ const textPadding = circleSize + 2;
14
+ const textSize = 10;
15
+ const maxTreeLevels = 25;
16
+ export default function SimilarityTree() {
17
+ const { height, view: { spectra: { activeTab, showSimilarityTree }, }, } = useChartData();
18
+ const spectrum = useSpectrum();
19
+ const format = useFormatNumberByNucleus(activeTab);
20
+ const { scaleX } = useScaleChecked();
21
+ const scaleY = (value) => (height * value) / maxTreeLevels;
22
+ const treeHeadLength = height / maxTreeLevels;
23
+ if (!spectrum || !showSimilarityTree || !isSpectrum1D(spectrum))
24
+ return null;
25
+ const { data: { x, re }, display: { color }, } = spectrum;
26
+ const tree = createTree({ x, y: re });
27
+ const data = mapTreeToArray(tree, 0);
28
+ const paths = [];
29
+ for (const { level, center, parentCenter, parentLevel } of data) {
30
+ if (parentCenter === undefined)
31
+ continue;
32
+ const startX = scaleX()(parentCenter);
33
+ const startY = scaleY(parentLevel);
34
+ const midY = startY + treeHeadLength / 2;
35
+ const endX = scaleX()(center);
36
+ const endY = scaleY(level);
37
+ const path = `M ${startX} ${startY} L ${startX} ${midY} L ${endX} ${midY} L${endX} ${endY}`;
38
+ paths.push(path);
39
+ }
40
+ return (_jsxs("g", { className: "similarity-tree", transform: `translate(0,${marginTop})`, children: [_jsx("path", { className: "tree-lines", d: paths.join(' '), fill: "none", stroke: lineColor }), ";", _jsx("g", { className: "tree-nodes", children: data.map(({ level, center }) => {
41
+ const x = scaleX()(center);
42
+ const y = scaleY(level);
43
+ return (_jsxs(Fragment, { children: [_jsx("circle", { cx: x, cy: y, r: circleSize, fill: color }), _jsx("text", { x: x + textPadding, y: y, textAnchor: "start", alignmentBaseline: "middle", fill: textColor, fontSize: textSize, children: format(center) })] }, `${level}${center}`));
44
+ }) })] }));
45
+ }
46
+ function mapTreeToArray(node, level, parentCenter = null, parentLevel = -1) {
47
+ if (!node)
48
+ return [];
49
+ const { center, sum } = node;
50
+ const result = [{ center, sum, level }];
51
+ for (const obj of result) {
52
+ if (parentCenter) {
53
+ obj.parentCenter = parentCenter;
54
+ obj.parentLevel = parentLevel;
55
+ }
56
+ }
57
+ const left = mapTreeToArray(node.left, level + 1, center, parentLevel + 1);
58
+ const right = mapTreeToArray(node.right, level + 1, center, parentLevel + 1);
59
+ return result.concat(left, right);
60
+ }
@@ -31,7 +31,7 @@ function InnerSpectraLegends({ spectra, legendsFields, }) {
31
31
  return (_jsx("g", { className: "spectra-intensity-legend", children: spectra.map((spectrum, index) => (_jsxs("g", { transform: `translate(5,${20 * (index + 1)})`, children: [_jsx("rect", { style: {
32
32
  ...styles.colorIndicator,
33
33
  fill: spectrum.display.color,
34
- } }), _jsx(SVGGroup, { space: 5, style: { transform: 'translate(12px,0)' }, children: legendsFields.map((field) => {
34
+ } }), _jsx(SVGGroup, { space: 5, transform: "translate(12 0)", children: legendsFields.map((field) => {
35
35
  const predefinedField = field;
36
36
  switch (predefinedField?.name) {
37
37
  case 'intensity':
@@ -9,6 +9,7 @@ import { BrushTracker, } from '../EventsTrackers/BrushTracker';
9
9
  import { MouseTracker } from '../EventsTrackers/MouseTracker';
10
10
  import { useChartData } from '../context/ChartContext';
11
11
  import { useDispatch } from '../context/DispatchContext';
12
+ import { useMapKeyModifiers } from '../context/KeyModifierContext';
12
13
  import { usePreferences } from '../context/PreferencesContext';
13
14
  import { ScaleProvider } from '../context/ScaleContext';
14
15
  import { useActiveSpectrum } from '../hooks/useActiveSpectrum';
@@ -22,6 +23,7 @@ import { options } from '../toolbar/ToolTypes';
22
23
  import Events from '../utility/Events';
23
24
  import Chart1D from './Chart1D';
24
25
  import FooterBanner from './FooterBanner';
26
+ import BaseLine from './tool/BaseLine';
25
27
  import PeakPointer from './tool/PeakPointer';
26
28
  import VerticalIndicator from './tool/VerticalIndicator';
27
29
  import XLabelPointer from './tool/XLabelPointer';
@@ -76,10 +78,12 @@ function Viewer1D({ emptyText = undefined }) {
76
78
  }
77
79
  const [isOpenAnalysisModal, openAnalysisModal, closeAnalysisModal] = useOnOff(false);
78
80
  const [brushData, setBrushData] = useState(null);
81
+ const { getModifiersKey, primaryKeyIdentifier } = useMapKeyModifiers();
79
82
  const handelBrushEnd = useCallback((brushData) => {
80
83
  //reset the brush start
81
84
  brushStartRef.current = null;
82
85
  setBrushData(brushData);
86
+ const keyModifiers = getModifiersKey(brushData);
83
87
  if (brushData.mouseButton === 'main') {
84
88
  const propagateEvent = () => {
85
89
  if (!scaleState.scaleX || !scaleState.scaleY)
@@ -92,109 +96,122 @@ function Viewer1D({ emptyText = undefined }) {
92
96
  range: [startXPPM, endXPPM].sort((a, b) => a - b),
93
97
  });
94
98
  };
95
- if (brushData.altKey) {
96
- switch (selectedTool) {
97
- case options.rangePicking.id: {
98
- openAnalysisModal();
99
- break;
100
- }
101
- default:
102
- break;
103
- }
104
- }
105
- else if (brushData.shiftKey) {
106
- switch (selectedTool) {
107
- case options.integral.id:
108
- dispatch({
109
- type: 'ADD_INTEGRAL',
110
- payload: brushData,
111
- });
112
- break;
113
- case options.rangePicking.id: {
114
- if (!activeSpectrum)
99
+ let executeDefaultAction = false;
100
+ switch (keyModifiers) {
101
+ // when Alt key is active
102
+ case primaryKeyIdentifier: {
103
+ switch (selectedTool) {
104
+ case options.integral.id:
105
+ dispatch({
106
+ type: 'ADD_INTEGRAL',
107
+ payload: brushData,
108
+ });
115
109
  break;
116
- dispatch({
117
- type: 'ADD_RANGE',
118
- payload: brushData,
119
- });
120
- break;
121
- }
122
- case options.multipleSpectraAnalysis.id:
123
- if (scaleState.scaleX) {
124
- const { startX, endX } = brushData;
125
- const start = scaleState.scaleX().invert(startX);
126
- const end = scaleState.scaleX().invert(endX);
110
+ case options.rangePicking.id: {
111
+ if (!activeSpectrum)
112
+ break;
113
+ dispatch({
114
+ type: 'ADD_RANGE',
115
+ payload: brushData,
116
+ });
117
+ break;
118
+ }
119
+ case options.multipleSpectraAnalysis.id:
120
+ if (scaleState.scaleX) {
121
+ const { startX, endX } = brushData;
122
+ const start = scaleState.scaleX().invert(startX);
123
+ const end = scaleState.scaleX().invert(endX);
124
+ dispatchPreferences({
125
+ type: 'ANALYZE_SPECTRA',
126
+ payload: {
127
+ start,
128
+ end,
129
+ nucleus: activeTab,
130
+ },
131
+ });
132
+ }
133
+ break;
134
+ case options.peakPicking.id:
135
+ dispatch({
136
+ type: 'ADD_PEAKS',
137
+ payload: brushData,
138
+ });
139
+ break;
140
+ case options.baselineCorrection.id:
141
+ dispatch({
142
+ type: 'ADD_BASE_LINE_ZONE',
143
+ payload: {
144
+ startX: brushData.startX,
145
+ endX: brushData.endX,
146
+ },
147
+ });
148
+ break;
149
+ case options.exclusionZones.id:
150
+ dispatch({
151
+ type: 'ADD_EXCLUSION_ZONE',
152
+ payload: { startX: brushData.startX, endX: brushData.endX },
153
+ });
154
+ break;
155
+ case options.matrixGenerationExclusionZones.id: {
156
+ const [from, to] = getRange(state, {
157
+ startX: brushData.startX,
158
+ endX: brushData.endX,
159
+ });
127
160
  dispatchPreferences({
128
- type: 'ANALYZE_SPECTRA',
161
+ type: 'ADD_MATRIX_GENERATION_EXCLUSION_ZONE',
129
162
  payload: {
130
- start,
131
- end,
163
+ zone: { from, to },
132
164
  nucleus: activeTab,
165
+ range: { from: xDomain[0], to: xDomain[1] },
133
166
  },
134
167
  });
168
+ break;
135
169
  }
136
- break;
137
- case options.peakPicking.id:
138
- dispatch({
139
- type: 'ADD_PEAKS',
140
- payload: brushData,
141
- });
142
- break;
143
- case options.baselineCorrection.id:
144
- dispatch({
145
- type: 'ADD_BASE_LINE_ZONE',
146
- payload: {
147
- startX: brushData.startX,
148
- endX: brushData.endX,
149
- },
150
- });
151
- break;
152
- case options.exclusionZones.id:
153
- dispatch({
154
- type: 'ADD_EXCLUSION_ZONE',
155
- payload: { startX: brushData.startX, endX: brushData.endX },
156
- });
157
- break;
158
- case options.matrixGenerationExclusionZones.id: {
159
- const [from, to] = getRange(state, {
160
- startX: brushData.startX,
161
- endX: brushData.endX,
162
- });
163
- dispatchPreferences({
164
- type: 'ADD_MATRIX_GENERATION_EXCLUSION_ZONE',
165
- payload: {
166
- zone: { from, to },
167
- nucleus: activeTab,
168
- range: { from: xDomain[0], to: xDomain[1] },
169
- },
170
- });
171
- break;
170
+ default:
171
+ executeDefaultAction = true;
172
+ break;
172
173
  }
173
- default:
174
- propagateEvent();
175
- break;
174
+ break;
176
175
  }
177
- }
178
- else {
179
- switch (selectedTool) {
180
- default:
181
- if (selectedTool != null) {
182
- dispatch({ type: 'BRUSH_END', payload: brushData });
176
+ case 'shift[false]_ctrl[false]_alt[true]': {
177
+ switch (selectedTool) {
178
+ case options.rangePicking.id: {
179
+ openAnalysisModal();
180
+ break;
183
181
  }
184
- break;
182
+ default:
183
+ executeDefaultAction = true;
184
+ break;
185
+ }
186
+ break;
187
+ }
188
+ default: {
189
+ executeDefaultAction = true;
190
+ break;
185
191
  }
186
192
  }
193
+ const tools = new Set(['zoom', 'databaseRangesSelection']);
194
+ const enableDefaultBrush = !tools.has(selectedTool) ||
195
+ (tools.has(selectedTool) && !brushData.shiftKey);
196
+ if (executeDefaultAction && selectedTool != null) {
197
+ if (enableDefaultBrush) {
198
+ dispatch({ type: 'BRUSH_END', payload: brushData });
199
+ }
200
+ propagateEvent();
201
+ }
187
202
  }
188
203
  }, [
189
- scaleState,
204
+ getModifiersKey,
190
205
  selectedTool,
191
- openAnalysisModal,
192
- activeSpectrum,
206
+ scaleState,
207
+ primaryKeyIdentifier,
193
208
  dispatch,
209
+ activeSpectrum,
194
210
  dispatchPreferences,
195
211
  activeTab,
196
- xDomain,
197
212
  state,
213
+ xDomain,
214
+ openAnalysisModal,
198
215
  ]);
199
216
  const handelOnDoubleClick = useCallback(() => {
200
217
  dispatch({
@@ -215,47 +232,48 @@ function Viewer1D({ emptyText = undefined }) {
215
232
  xPPM,
216
233
  });
217
234
  };
218
- if (event.shiftKey) {
219
- switch (selectedTool) {
220
- case options.peakPicking.id:
221
- dispatch({
222
- type: 'ADD_PEAK',
223
- payload: event,
224
- });
225
- break;
226
- case options.editRange.id:
227
- propagateEvent();
228
- break;
229
- case options.integral.id:
230
- dispatch({
231
- type: 'CUT_INTEGRAL',
232
- payload: { cutValue: xPPM },
233
- });
234
- break;
235
- case options.rangePicking.id:
236
- dispatch({
237
- type: 'CUT_RANGE',
238
- payload: { cutValue: xPPM },
239
- });
240
- break;
241
- case options.phaseCorrection.id:
242
- dispatch({
243
- type: 'SET_ONE_DIMENSION_PIVOT_POINT',
244
- payload: {
245
- value: event.x,
246
- },
247
- });
248
- break;
249
- default:
250
- break;
251
- }
252
- }
253
- else {
254
- switch (selectedTool) {
255
- default:
235
+ const keyModifiers = getModifiersKey(event);
236
+ switch (keyModifiers) {
237
+ case primaryKeyIdentifier: {
238
+ switch (selectedTool) {
239
+ case options.peakPicking.id:
240
+ dispatch({
241
+ type: 'ADD_PEAK',
242
+ payload: event,
243
+ });
244
+ break;
245
+ case options.editRange.id:
246
+ propagateEvent();
247
+ break;
248
+ case options.integral.id:
249
+ dispatch({
250
+ type: 'CUT_INTEGRAL',
251
+ payload: { cutValue: xPPM },
252
+ });
253
+ break;
254
+ case options.rangePicking.id:
255
+ dispatch({
256
+ type: 'CUT_RANGE',
257
+ payload: { cutValue: xPPM },
258
+ });
259
+ break;
260
+ case options.phaseCorrection.id:
261
+ dispatch({
262
+ type: 'SET_ONE_DIMENSION_PIVOT_POINT',
263
+ payload: {
264
+ value: event.x,
265
+ },
266
+ });
267
+ break;
268
+ default:
269
+ break;
270
+ }
271
+ break;
256
272
  }
273
+ default:
274
+ break;
257
275
  }
258
- }, [dispatch, scaleState, selectedTool]);
276
+ }, [dispatch, getModifiersKey, primaryKeyIdentifier, scaleState, selectedTool]);
259
277
  return (_jsxs(ScaleProvider, { value: scaleState, children: [_jsx(ResponsiveChart, { children: ({ height, width }) => (_jsx(ViewerResponsiveWrapper, { height: height, width: width, children: _jsxs("div", { style: { height: '100%', position: 'relative' }, children: [_jsx(Spinner, { isLoading: isLoading, emptyText: emptyText }), scaleState.scaleX &&
260
278
  scaleState.scaleY &&
261
279
  data &&
@@ -269,6 +287,6 @@ function Viewer1D({ emptyText = undefined }) {
269
287
  width: '100%',
270
288
  height: `100%`,
271
289
  position: 'absolute',
272
- }, children: [_jsx(CrossLinePointer, {}), _jsx(BrushXY, { brushType: BRUSH_TYPE.X }), _jsx(XLabelPointer, {}), _jsx(PeakPointer, {}), _jsx(VerticalIndicator, {}), _jsx(FooterBanner, {}), _jsx(Chart1D, { width: widthProp, height: heightProp, margin: margin, mode: mode, displayerKey: displayerKey })] }) }))] }) })) }), brushData && (_jsx(MultipletAnalysisModal, { isOpen: isOpenAnalysisModal, onClose: closeAnalysisModal, data: data, activeSpectrum: activeSpectrum, scaleX: scaleState.scaleX, ...brushData }))] }));
290
+ }, children: [_jsx(CrossLinePointer, {}), _jsx(BrushXY, { brushType: BRUSH_TYPE.X }), _jsx(XLabelPointer, {}), _jsx(PeakPointer, {}), _jsx(VerticalIndicator, {}), _jsx(FooterBanner, {}), _jsx(Chart1D, { width: widthProp, height: heightProp, margin: margin, mode: mode, displayerKey: displayerKey }), _jsx(BaseLine, {})] }) }))] }) })) }), brushData && (_jsx(MultipletAnalysisModal, { isOpen: isOpenAnalysisModal, onClose: closeAnalysisModal, data: data, activeSpectrum: activeSpectrum, scaleX: scaleState.scaleX, ...brushData }))] }));
273
291
  }
274
292
  export default Viewer1D;
@@ -6,5 +6,5 @@ export default function JsCoupling({ value }) {
6
6
  const [isOver, setOver] = useState(false);
7
7
  if (!scaleY)
8
8
  return null;
9
- return (_jsxs("g", { className: "coupling", style: { transform: `translate(0px,${scaleY(value)}px)` }, children: [_jsx("circle", { onMouseEnter: () => setOver(true), onMouseLeave: () => setOver(false), cx: 0, cy: 0, r: 4, fill: `hsl(${(value * 360) / maxValue},100%,${isOver ? 45 : 50}%)`, pointerEvents: "all" }), isOver && (_jsxs("g", { style: { transform: `translate(0px,15px)` }, children: [_jsx("text", { pointerEvents: "none", stroke: "white", strokeWidth: "0.6em", fontSize: "11px", dominantBaseline: "middle", textAnchor: "end", children: `${value.toFixed(1)} Hz` }), _jsx("text", { pointerEvents: "none", stroke: "black", fontSize: "11px", dominantBaseline: "middle", textAnchor: "end", children: `${value.toFixed(1)} Hz` })] }))] }));
9
+ return (_jsxs("g", { className: "coupling", transform: `translate(0 ${scaleY(value)})`, children: [_jsx("circle", { onMouseEnter: () => setOver(true), onMouseLeave: () => setOver(false), cx: 0, cy: 0, r: 4, fill: `hsl(${(value * 360) / maxValue},100%,${isOver ? 45 : 50}%)`, pointerEvents: "all" }), isOver && (_jsxs("g", { transform: "translate(0 15)", children: [_jsx("text", { pointerEvents: "none", stroke: "white", strokeWidth: "0.6em", fontSize: "11px", dominantBaseline: "middle", textAnchor: "end", children: `${value.toFixed(1)} Hz` }), _jsx("text", { pointerEvents: "none", stroke: "black", fontSize: "11px", dominantBaseline: "middle", textAnchor: "end", children: `${value.toFixed(1)} Hz` })] }))] }));
10
10
  }
@@ -1,12 +1,6 @@
1
1
  import { Range } from 'nmr-processing';
2
- import { CSSProperties } from 'react';
3
2
  interface MultiplicityTreeProps {
4
3
  range: Range;
5
- labelOptions?: {
6
- distance: number;
7
- fontSize: CSSProperties['fontSize'];
8
- };
9
- onUnlink: (index: number) => void;
10
4
  }
11
- export declare function MultiplicityTree(props: MultiplicityTreeProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
5
+ export default function MultiplicityTree(props: MultiplicityTreeProps): import("@emotion/react/jsx-runtime").JSX.Element[] | null;
12
6
  export {};