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
@@ -5,14 +5,13 @@ import { SvgNmrOverlay } from 'cheminfo-font';
5
5
  import { useCallback, useState, useRef, memo } from 'react';
6
6
  import { FaChartBar, FaFileExport } from 'react-icons/fa';
7
7
  import { IoPulseOutline } from 'react-icons/io5';
8
+ import { Toolbar } from 'react-science/ui';
8
9
  import { useToggle } from 'react-use';
9
10
  import { getDataAsString, generateAnalyzeSpectra, } from '../../../data/data1d/multipleSpectraAnalysis';
10
11
  import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
11
12
  import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
12
13
  import { useChartData } from '../../context/ChartContext';
13
14
  import { useDispatch } from '../../context/DispatchContext';
14
- import ActiveButton from '../../elements/ActiveButton';
15
- import Button from '../../elements/ButtonToolTip';
16
15
  import { useAlert } from '../../elements/popup/Alert';
17
16
  import { usePanelPreferences } from '../../hooks/usePanelPreferences';
18
17
  import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
@@ -52,6 +51,13 @@ function MultipleSpectraAnalysisPanelInner({ activeTab, spectra, showLegend, dis
52
51
  return;
53
52
  void rawWriteWithType(data).then(() => alert.success('Data copied to clipboard'));
54
53
  }, [alert, rawWriteWithType, spectra, spectraAnalysis, spectraPreferences]);
54
+ function handleSpectraCalibration() {
55
+ setCalibration((value) => {
56
+ if (value)
57
+ dispatch({ type: 'RESET_SELECTED_TOOL' });
58
+ return !value;
59
+ });
60
+ }
55
61
  return (_jsxs("div", { css: [
56
62
  tablePanelStyle,
57
63
  isFlipped &&
@@ -60,13 +66,7 @@ function MultipleSpectraAnalysisPanelInner({ activeTab, spectra, showLegend, dis
60
66
  position: relative;
61
67
  }
62
68
  `,
63
- ], children: [!isFlipped && (_jsxs(DefaultPanelHeader, { deleteToolTip: "Delete All Peaks", showSettingButton: true, canDelete: false, onSettingClick: settingsPanelHandler, children: [_jsx(Button, { popupTitle: "Copy To Clipboard", onClick: copyToClipboardHandler, children: _jsx(FaFileExport, {}) }), displayerMode === '1D' && (_jsxs(_Fragment, { children: [_jsx(Button, { popupTitle: "Spectra calibration", onClick: () => {
64
- setCalibration((value) => {
65
- if (value)
66
- dispatch({ type: 'RESET_SELECTED_TOOL' });
67
- return !value;
68
- });
69
- }, children: _jsx(SvgNmrOverlay, { style: { fontSize: '16px' } }) }), _jsx(ActiveButton, { popupTitle: "Y spectra tracker", popupPlacement: "right", onClick: showTrackerHandler, value: showLegend, children: _jsx(IoPulseOutline, {}) }, `${showLegend}`), _jsx(ActiveButton, { popupTitle: `${!showAnalysisChart ? 'Show' : 'Hide'} analysis chart`, popupPlacement: "right", onClick: () => toggleAnalysisChart(), value: showAnalysisChart, style: { marginLeft: '5px' }, children: _jsx(FaChartBar, {}) })] }))] })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: isFlipped ? (_jsx(MultipleSpectraAnalysisPreferences, { data: spectraAnalysis, activeTab: activeTab, onAfterSave: afterSaveHandler, ref: settingRef })) : calibration ? (_jsx(AlignSpectra, { nucleus: activeTab, onClose: () => setCalibration(false) })) : (_jsxs("div", { style: { overflow: 'auto', maxHeight: '100%' }, children: [showAnalysisChart && (_jsx(AnalysisChart, { spectraAnalysisData: spectraAnalysis })), _jsx(MultipleSpectraAnalysisTable, { data: spectraAnalysis, resortSpectra: preferences.analysisOptions.resortSpectra, activeTab: activeTab })] })) }), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Spectra Analysis" })] }));
69
+ ], children: [!isFlipped && (_jsx(DefaultPanelHeader, { deleteToolTip: "Delete All Peaks", showSettingButton: true, canDelete: false, onSettingClick: settingsPanelHandler, children: _jsxs(Toolbar, { children: [_jsx(Toolbar.Item, { icon: _jsx(FaFileExport, {}), title: "Copy To Clipboard", onClick: copyToClipboardHandler }), displayerMode === '1D' && (_jsxs(_Fragment, { children: [_jsx(Toolbar.Item, { icon: _jsx(SvgNmrOverlay, {}), title: "Spectra calibration", onClick: handleSpectraCalibration, active: calibration }), _jsx(Toolbar.Item, { icon: _jsx(IoPulseOutline, {}), title: "Y spectra tracker", onClick: showTrackerHandler, active: showLegend }), _jsx(Toolbar.Item, { icon: _jsx(FaChartBar, {}), title: `${!showAnalysisChart ? 'Show' : 'Hide'} analysis chart`, onClick: toggleAnalysisChart, active: showAnalysisChart })] }))] }) })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: isFlipped ? (_jsx(MultipleSpectraAnalysisPreferences, { data: spectraAnalysis, activeTab: activeTab, onAfterSave: afterSaveHandler, ref: settingRef })) : calibration ? (_jsx(AlignSpectra, { nucleus: activeTab, onClose: () => setCalibration(false) })) : (_jsxs("div", { style: { overflow: 'auto', maxHeight: '100%' }, children: [showAnalysisChart && (_jsx(AnalysisChart, { spectraAnalysisData: spectraAnalysis })), _jsx(MultipleSpectraAnalysisTable, { data: spectraAnalysis, resortSpectra: preferences.analysisOptions.resortSpectra, activeTab: activeTab })] })) }), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Spectra Analysis" })] }));
70
70
  }
71
71
  const MemoizedMultipleSpectraAnalysisPanel = memo(MultipleSpectraAnalysisPanelInner);
72
72
  export default function MultipleSpectraAnalysisPanel() {
@@ -11,10 +11,10 @@ const SPIN_SYSTEMS = getSpinSystems().map((key) => ({
11
11
  }));
12
12
  const labelStyle = {
13
13
  label: { fontSize: '10px' },
14
- wrapper: { display: 'flex', alignItems: 'center', height: '100%' },
15
- container: { padding: '0 5px', height: '100%' },
14
+ wrapper: { display: 'flex', alignItems: 'center' },
15
+ container: { padding: '0 5px' },
16
16
  };
17
- const selectStyles = { width: '100%', minWidth: '75px', fontSize: '10px' };
17
+ const selectStyles = { width: '100%', minWidth: '80px', fontSize: '10px' };
18
18
  export default function SpectrumSimulationSimpleOptions({ onSpinSystemChange, spinSystem, }) {
19
19
  return (_jsxs("div", { style: {
20
20
  display: 'flex',
@@ -29,6 +29,7 @@ export function getDefaultViewState() {
29
29
  activeSpectra: {},
30
30
  activeTab: '',
31
31
  showLegend: false,
32
+ showSimilarityTree: false,
32
33
  selectReferences: {},
33
34
  },
34
35
  zoom: {
@@ -289,6 +290,8 @@ function innerSpectrumReducer(draft, action) {
289
290
  return ToolsActions.handleAddBaseLineZone(draft, action);
290
291
  case 'DELETE_BASE_LINE_ZONE':
291
292
  return ToolsActions.handleDeleteBaseLineZone(draft, action);
293
+ case 'RESIZE_BASE_LINE_ZONE':
294
+ return ToolsActions.handleResizeBaseLineZone(draft, action);
292
295
  case 'SET_2D_LEVEL':
293
296
  return ToolsActions.levelChangeHandler(draft, action);
294
297
  case 'ADD_MOLECULE':
@@ -393,6 +396,8 @@ function innerSpectrumReducer(draft, action) {
393
396
  return DatabaseActions.handleResurrectSpectrumFromRanges(draft, action);
394
397
  case 'RESURRECTING_SPECTRUM_FROM_JCAMP':
395
398
  return DatabaseActions.handleResurrectSpectrumFromJcamp(draft, action);
399
+ case 'TOGGLE_SIMILARITY_TREE':
400
+ return DatabaseActions.handleToggleSimilarityTree(draft);
396
401
  case 'SET_AUTOMATIC_ASSIGNMENTS':
397
402
  return AssignmentsActions.handleSetAutomaticAssignments(draft, action);
398
403
  case 'SECRET_THROW_ERROR': {
@@ -12,7 +12,8 @@ type ResurrectSpectrumFromRangesAction = ActionType<'RESURRECTING_SPECTRUM_FROM_
12
12
  ranges: NMRRange[];
13
13
  info: ResurrectSpectrumInfo;
14
14
  }>;
15
- export type DatabaseActions = ResurrectSpectrumFromJcampAction | ResurrectSpectrumFromRangesAction;
15
+ export type DatabaseActions = ActionType<'TOGGLE_SIMILARITY_TREE'> | ResurrectSpectrumFromJcampAction | ResurrectSpectrumFromRangesAction;
16
16
  declare function handleResurrectSpectrumFromJcamp(draft: Draft<State>, action: ResurrectSpectrumFromJcampAction): void;
17
17
  declare function handleResurrectSpectrumFromRanges(draft: Draft<State>, action: ResurrectSpectrumFromRangesAction): void;
18
- export { handleResurrectSpectrumFromRanges, handleResurrectSpectrumFromJcamp };
18
+ declare function handleToggleSimilarityTree(draft: Draft<State>): void;
19
+ export { handleResurrectSpectrumFromRanges, handleResurrectSpectrumFromJcamp, handleToggleSimilarityTree, };
@@ -29,4 +29,8 @@ function handleResurrectSpectrumFromRanges(draft, action) {
29
29
  setZoom(draft, { scale: 0.8, spectrumID: datum.id });
30
30
  }
31
31
  }
32
- export { handleResurrectSpectrumFromRanges, handleResurrectSpectrumFromJcamp };
32
+ function handleToggleSimilarityTree(draft) {
33
+ draft.view.spectra.showSimilarityTree =
34
+ !draft.view.spectra.showSimilarityTree;
35
+ }
36
+ export { handleResurrectSpectrumFromRanges, handleResurrectSpectrumFromJcamp, handleToggleSimilarityTree, };
@@ -82,7 +82,7 @@ type SetTwoDimensionPhaseCorrectionPivotPoint = ActionType<'SET_TWO_DIMENSION_PI
82
82
  y: number;
83
83
  }>;
84
84
  export type FiltersActions = ShiftSpectrumAlongXAxisAction | ApodizationFilterAction | ApodizationFilterLiveAction | ZeroFillingFilterAction | ZeroFillingFilterLiveAction | ManualPhaseCorrectionFilterAction | BaselineCorrectionFilterAction | BaselineCorrectionFilterLiveAction | EnableFilterAction | DeleteFilterAction | DeleteSpectraFilterAction | SetFilterSnapshotAction | AddExclusionZoneAction | DeleteExclusionZoneAction | ApplySignalProcessingAction | AddPhaseCorrectionTraceAction | ChangePhaseCorrectionDirectionAction | DeletePhaseCorrectionTrace | SetOneDimensionPhaseCorrectionPivotPoint | SetTwoDimensionPhaseCorrectionPivotPoint | ActionType<'APPLY_FFT_FILTER' | 'APPLY_FFT_DIMENSION_1_FILTER' | 'APPLY_FFT_DIMENSION_2_FILTER' | 'APPLY_AUTO_PHASE_CORRECTION_FILTER' | 'APPLY_ABSOLUTE_FILTER'>;
85
- interface RollbackSpectrumByFilterOptions {
85
+ export interface RollbackSpectrumByFilterOptions {
86
86
  applyFilter?: boolean;
87
87
  reset?: boolean;
88
88
  searchBy?: 'id' | 'name';
@@ -91,9 +91,8 @@ interface RollbackSpectrumByFilterOptions {
91
91
  triggerSource?: 'Apply' | 'none';
92
92
  }
93
93
  declare function rollbackSpectrumByFilter(draft: Draft<State>, options?: RollbackSpectrumByFilterOptions): void;
94
- interface RollbackSpectrumOptions {
95
- updateFilterViewOptions?: boolean;
96
- filterKey: string;
94
+ export interface RollbackSpectrumOptions {
95
+ filterKey?: string;
97
96
  reset?: boolean;
98
97
  }
99
98
  declare function rollbackSpectrum(draft: Draft<State>, options: RollbackSpectrumOptions): void;
@@ -1,7 +1,7 @@
1
1
  import { v4 } from '@lukeed/uuid';
2
2
  import { current } from 'immer';
3
3
  import { xFindClosestIndex } from 'ml-spectra-processing';
4
- import { Filters, FiltersManager, } from 'nmr-processing';
4
+ import { Filters, FiltersManager, getBaselineZones, } from 'nmr-processing';
5
5
  import { defaultApodizationOptions } from '../../../data/constants/DefaultApodizationOptions';
6
6
  import { getSlice, isSpectrum2D } from '../../../data/data2d/Spectrum2D';
7
7
  import { getProjection } from '../../../data/data2d/Spectrum2D/getMissingProjection';
@@ -20,12 +20,32 @@ import { setDomain, setMode } from './DomainActions';
20
20
  import { changeSpectrumVerticalAlignment } from './PreferencesActions';
21
21
  import { activateTool, resetSelectedTool } from './ToolsActions';
22
22
  const { fft, fftDimension1, fftDimension2, apodization, baselineCorrection, phaseCorrection, zeroFilling, shiftX, shift2DX, shift2DY, exclusionZones, signalProcessing, } = Filters;
23
- function getFilterUpdateDomainRules(filterName) {
24
- return (Filters[filterName]?.DOMAIN_UPDATE_RULES || {
23
+ function getFilterUpdateDomainRules(filterName, defaultRule) {
24
+ return (Filters[filterName]?.DOMAIN_UPDATE_RULES ||
25
+ defaultRule || {
25
26
  updateXDomain: false,
26
27
  updateYDomain: false,
27
28
  });
28
29
  }
30
+ function getFilterDomain(datum, options) {
31
+ const { startIndex, lastIndex } = options;
32
+ const updateDomainOptions = {
33
+ updateXDomain: false,
34
+ updateYDomain: false,
35
+ };
36
+ if (datum?.filters?.length === 0)
37
+ return updateDomainOptions;
38
+ for (let i = startIndex; i <= lastIndex; i++) {
39
+ const { updateXDomain, updateYDomain } = getFilterUpdateDomainRules(datum.filters[i].name);
40
+ if (!updateDomainOptions.updateXDomain) {
41
+ updateDomainOptions.updateXDomain = updateXDomain;
42
+ }
43
+ if (!updateDomainOptions.updateYDomain) {
44
+ updateDomainOptions.updateYDomain = updateYDomain;
45
+ }
46
+ }
47
+ return updateDomainOptions;
48
+ }
29
49
  function rollbackSpectrumByFilter(draft, options) {
30
50
  const { applyFilter = true, searchBy = 'id', reset = false, key, activeSpectrum, triggerSource = 'none', } = options || {};
31
51
  const currentActiveSpectrum = activeSpectrum || getActiveSpectrum(draft);
@@ -40,47 +60,53 @@ function rollbackSpectrumByFilter(draft, options) {
40
60
  const datum = draft.data[index];
41
61
  previousIsFid = datum.info.isFid;
42
62
  const filterIndex = datum.filters.findIndex((f) => f[searchBy] === key);
43
- const activeFilterId = draft.toolOptions.data.activeFilterID;
44
63
  if (filterIndex !== -1 && !reset) {
45
- const filters = datum.filters.slice(0, filterIndex || 1);
64
+ const { activeFilterID } = draft.toolOptions.data;
65
+ const activeFilterIndex = activeFilterID
66
+ ? datum.filters.findIndex((f) => f.id === activeFilterID)
67
+ : datum.filters.length - 1;
46
68
  //set active filter
47
- draft.toolOptions.data.activeFilterID = datum.filters[filterIndex]?.id;
48
- if (filters.length > 0) {
49
- for (let i = 0; i <= filterIndex; i++) {
50
- const { updateXDomain, updateYDomain } = getFilterUpdateDomainRules(datum.filters[i].name);
51
- updateDomainOptions.updateXDomain =
52
- updateXDomain || updateDomainOptions.updateXDomain;
53
- updateDomainOptions.updateYDomain =
54
- updateYDomain || updateDomainOptions.updateYDomain;
55
- }
56
- FiltersManager.reapplyFilters(datum, filters);
57
- }
69
+ draft.toolOptions.data.activeFilterID =
70
+ datum.filters?.[filterIndex]?.id || null;
71
+ const filters = datum.filters.slice(0, filterIndex || 1);
72
+ updateDomainOptions = getFilterDomain(datum, {
73
+ startIndex: Math.min(activeFilterIndex, filterIndex),
74
+ lastIndex: Math.max(activeFilterIndex, filterIndex),
75
+ });
76
+ FiltersManager.reapplyFilters(datum, filters);
58
77
  draft.tempData = current(draft).data;
59
78
  // apply the current Filters
60
79
  if (applyFilter) {
61
- FiltersManager.reapplyFilters(datum, datum.filters.slice(0, filterIndex + 1));
80
+ const { name, value } = datum.filters[filterIndex];
81
+ Filters[name].apply(datum, value);
62
82
  }
63
83
  currentIsFid = datum.info.isFid;
64
84
  //if we still point to the same filter then close the filter options panel and reset the selected tool to default one (zoom tool)
65
- if (activeFilterId === datum.filters[filterIndex].id &&
85
+ if (activeFilterID === datum.filters[filterIndex].id &&
66
86
  triggerSource === 'Apply') {
67
87
  draft.toolOptions.selectedOptionPanel = null;
68
88
  draft.toolOptions.selectedTool = 'zoom';
69
89
  }
70
90
  }
71
- else {
91
+ if (filterIndex === -1 || reset) {
92
+ if (draft.tempData) {
93
+ FiltersManager.reapplyFilters(datum);
94
+ }
72
95
  //if the filter is not exists, create a clone of the current data
73
96
  draft.tempData = current(draft).data;
74
97
  }
75
98
  // re-implement all filters and rest all view property that related to filters
76
99
  if (reset) {
100
+ draft.toolOptions.data.activeFilterID = null;
77
101
  draft.tempData = null;
78
- FiltersManager.reapplyFilters(datum);
79
- updateDomainOptions = { updateXDomain: true, updateYDomain: true };
102
+ if (datum.filters.length > 0 && filterIndex !== -1) {
103
+ updateDomainOptions = getFilterDomain(datum, {
104
+ startIndex: filterIndex,
105
+ lastIndex: datum.filters.length - 1,
106
+ });
107
+ }
80
108
  const { toolOptions: { data }, } = getInitialState();
81
109
  draft.toolOptions.data = data;
82
- draft.toolOptions.selectedOptionPanel = null;
83
- draft.toolOptions.selectedTool = 'zoom';
84
110
  currentIsFid = datum.info.isFid;
85
111
  }
86
112
  }
@@ -91,28 +117,51 @@ function rollbackSpectrumByFilter(draft, options) {
91
117
  }
92
118
  }
93
119
  function rollbackSpectrum(draft, options) {
94
- const { filterKey, reset = false, updateFilterViewOptions = true } = options;
120
+ const { filterKey, reset = false } = options;
95
121
  //return back the spectra data to point of time before applying a specific filter
96
- const applyFilter = [
97
- phaseCorrection.id,
98
- fft.id,
99
- shiftX.id,
100
- shift2DX.id,
101
- shift2DY.id,
102
- signalProcessing.id,
103
- ].includes(filterKey);
122
+ const applyFilter = !filterKey
123
+ ? true
124
+ : [
125
+ phaseCorrection.id,
126
+ fft.id,
127
+ shiftX.id,
128
+ shift2DX.id,
129
+ shift2DY.id,
130
+ signalProcessing.id,
131
+ ].includes(filterKey);
132
+ beforeRollback(draft, filterKey);
104
133
  rollbackSpectrumByFilter(draft, {
105
134
  searchBy: 'name',
106
135
  key: filterKey,
107
136
  applyFilter,
108
137
  reset,
109
138
  });
110
- if (updateFilterViewOptions) {
111
- updateFilterOptionsInView(draft, filterKey);
112
- }
139
+ afterRollback(draft, filterKey);
113
140
  }
114
- function updateFilterOptionsInView(draft, filterKey) {
141
+ function beforeRollback(draft, filterKey) {
115
142
  const activeSpectrum = getActiveSpectrum(draft);
143
+ switch (filterKey) {
144
+ case baselineCorrection.id: {
145
+ if (activeSpectrum) {
146
+ const datum = current(draft).data[activeSpectrum.index];
147
+ const baselineCorrectionFilter = datum.filters.find((filter) => filter.name === Tools.baselineCorrection.id);
148
+ if (!baselineCorrectionFilter ||
149
+ (baselineCorrectionFilter &&
150
+ baselineCorrectionFilter.value.zones?.length === 0)) {
151
+ draft.toolOptions.data.baselineCorrection.zones = getBaselineZones(datum.data);
152
+ }
153
+ else {
154
+ draft.toolOptions.data.baselineCorrection.zones =
155
+ baselineCorrectionFilter.value.zones;
156
+ }
157
+ }
158
+ break;
159
+ }
160
+ default:
161
+ break;
162
+ }
163
+ }
164
+ function afterRollback(draft, filterKey) {
116
165
  switch (filterKey) {
117
166
  case phaseCorrection.id: {
118
167
  // look for the strongest peak to set it as a pivot
@@ -123,18 +172,6 @@ function updateFilterOptionsInView(draft, filterKey) {
123
172
  draft.toolOptions.data.pivot = { value: xValue, index };
124
173
  break;
125
174
  }
126
- case baselineCorrection.id: {
127
- if (activeSpectrum) {
128
- const baselineCorrectionFilter = current(draft).data[activeSpectrum.index].filters.find((filter) => filter.name === Tools.baselineCorrection.id);
129
- if (baselineCorrectionFilter) {
130
- draft.toolOptions.data.baselineCorrection.zones =
131
- baselineCorrectionFilter
132
- ? baselineCorrectionFilter.value.zones
133
- : [];
134
- }
135
- }
136
- break;
137
- }
138
175
  case apodization.id: {
139
176
  draft.toolOptions.data.apodizationOptions = defaultApodizationOptions;
140
177
  break;
@@ -170,16 +207,17 @@ function disableLivePreview(draft, id) {
170
207
  const index = activeSpectrum.index;
171
208
  const { data } = draft.tempData[index];
172
209
  draft.data[index].data = data;
173
- setDomain(draft);
210
+ if (baselineCorrection.id !== id) {
211
+ setDomain(draft);
212
+ }
174
213
  // reset default options
175
214
  switch (id) {
176
- case apodization.name: {
215
+ case apodization.id: {
177
216
  draft.toolOptions.data.apodizationOptions = defaultApodizationOptions;
178
217
  break;
179
218
  }
180
- default: {
181
- return null;
182
- }
219
+ default:
220
+ break;
183
221
  }
184
222
  }
185
223
  }
@@ -526,7 +564,7 @@ function calculateBaseLineCorrection(draft, baseLineOptions) {
526
564
  ...draft.toolOptions.data.baselineCorrection,
527
565
  ...(baseLineOptions && baseLineOptions),
528
566
  };
529
- const { zones, options, livePreview } = draft.toolOptions.data.baselineCorrection;
567
+ const { zones, options, livePreview } = current(draft).toolOptions.data.baselineCorrection;
530
568
  if (livePreview) {
531
569
  const _data = { data: { x, re, im }, info };
532
570
  baselineCorrection.apply(_data, {
@@ -603,7 +641,6 @@ function handleSetFilterSnapshotHandler(draft, action) {
603
641
  activateTool(draft, { toolId: filterKey, reset });
604
642
  }
605
643
  else {
606
- resetSelectedTool(draft);
607
644
  rollbackSpectrum(draft, { filterKey, reset });
608
645
  }
609
646
  }
@@ -1,3 +1,4 @@
1
+ import { produce } from 'immer';
1
2
  import lodashMerge from 'lodash/merge';
2
3
  import lodashMergeWith from 'lodash/mergeWith';
3
4
  import { buildCorrelationData } from 'nmr-correlation';
@@ -113,14 +114,15 @@ function initData(draft, action, options = {}) {
113
114
  const viewState = view;
114
115
  if (data?.spectra?.length || forceInitialize) {
115
116
  const state = getInitialState();
116
- setData(state, action.payload);
117
- setActiveTab(state, { tab: viewState?.spectra?.activeTab || '' });
118
- state.width = draft.width;
119
- state.height = draft.height;
120
- setPreferences(state, viewState);
121
- state.isLoading = false;
122
- state.actionType = action.type;
123
- return state;
117
+ return produce(state, (initialDraft) => {
118
+ setData(initialDraft, action.payload);
119
+ setActiveTab(initialDraft, { tab: viewState?.spectra?.activeTab || '' });
120
+ initialDraft.width = draft.width;
121
+ initialDraft.height = draft.height;
122
+ setPreferences(initialDraft, viewState);
123
+ initialDraft.isLoading = false;
124
+ initialDraft.actionType = action.type;
125
+ });
124
126
  }
125
127
  else {
126
128
  if (view) {
@@ -1,5 +1,6 @@
1
1
  import { Draft } from 'immer';
2
2
  import { Spectrum, Display1D, Display2D } from 'nmr-load-save';
3
+ import { NMRRange } from 'nmr-processing';
3
4
  import { SpectrumSimulationOptions } from '../../../data/data1d/spectrumSimulation';
4
5
  import { Nuclei, Nucleus } from '../../../data/types/common/Nucleus';
5
6
  import { State } from '../Reducer';
@@ -33,7 +34,13 @@ type AlignSpectraAction = ActionType<'ALIGN_SPECTRA', {
33
34
  targetX: number;
34
35
  }>;
35
36
  type GenerateSpectrumFromPublicationStringAction = ActionType<'GENERATE_SPECTRUM_FROM_PUBLICATION_STRING', {
36
- publicationText: string;
37
+ ranges: NMRRange[];
38
+ info: {
39
+ nucleus: string;
40
+ solvent: string;
41
+ frequency: number;
42
+ name: string;
43
+ };
37
44
  }>;
38
45
  type ImportSpectraMetaInfoAction = ActionType<'IMPORT_SPECTRA_META_INFO', {
39
46
  spectraMeta: Record<string, Record<string, any>>;
@@ -3,7 +3,7 @@ import lodashGet from 'lodash/get';
3
3
  import omitBy from 'lodash/omitBy';
4
4
  import lodashSet from 'lodash/set';
5
5
  import { Filters, FiltersManager } from 'nmr-processing';
6
- import { generateSpectrumFromPublicationString, getReferenceShift, isSpectrum1D, get1DColor, initiateDatum1D, } from '../../../data/data1d/Spectrum1D';
6
+ import { getReferenceShift, isSpectrum1D, get1DColor, initiateDatum1D, generateSpectrumFromRanges, } from '../../../data/data1d/Spectrum1D';
7
7
  import { simulateSpectrum, } from '../../../data/data1d/spectrumSimulation';
8
8
  import { getMissingProjection, isSpectrum2D, get2DColor, } from '../../../data/data2d/Spectrum2D';
9
9
  import { contoursManager } from '../../../data/data2d/Spectrum2D/contours';
@@ -300,8 +300,8 @@ function handleAlignSpectraHandler(draft, action) {
300
300
  }
301
301
  //action
302
302
  function handleGenerateSpectrumFromPublicationStringHandler(draft, action) {
303
- const publicationString = action.payload.publicationText;
304
- const spectrum = generateSpectrumFromPublicationString(publicationString, draft.usedColors);
303
+ const { ranges, info } = action.payload;
304
+ const spectrum = generateSpectrumFromRanges(ranges, info, draft.usedColors);
305
305
  if (spectrum) {
306
306
  draft.data.push(spectrum);
307
307
  setActiveTab(draft);
@@ -1,4 +1,5 @@
1
1
  import { Draft } from 'immer';
2
+ import { BaselineCorrectionZone } from 'nmr-processing';
2
3
  import { Nucleus } from '../../../data/types/common/Nucleus';
3
4
  import { Layout } from '../../2d/utilities/DimensionLayout';
4
5
  import { Tool } from '../../toolbar/ToolTypes';
@@ -25,6 +26,7 @@ type AddBaseLineZoneAction = ActionType<'ADD_BASE_LINE_ZONE', {
25
26
  startX: number;
26
27
  endX: number;
27
28
  }>;
29
+ type ResizeBaseLineZoneAction = ActionType<'RESIZE_BASE_LINE_ZONE', BaselineCorrectionZone>;
28
30
  type DeleteBaseLineZoneAction = ActionType<'DELETE_BASE_LINE_ZONE', {
29
31
  id: string;
30
32
  }>;
@@ -45,18 +47,19 @@ type LevelChangeAction = ActionType<'SET_2D_LEVEL', {
45
47
  deltaY: number;
46
48
  shiftKey: boolean;
47
49
  }>;
48
- export type ToolsActions = ActionType<'TOGGLE_REAL_IMAGINARY_VISIBILITY' | 'RESET_SELECTED_TOOL' | 'SET_SPECTRUMS_VERTICAL_ALIGN' | 'CHANGE_SPECTRUM_DISPLAY_VIEW_MODE' | 'SET_SPECTRA_SAME_TOP' | 'RESET_SPECTRA_SCALE'> | SetSelectedToolAction | AddBaseLineZoneAction | DeleteBaseLineZoneAction | BrushEndAction | ZoomAction | ZoomOutAction | SetActiveTabAction | LevelChangeAction;
50
+ export type ToolsActions = ActionType<'TOGGLE_REAL_IMAGINARY_VISIBILITY' | 'RESET_SELECTED_TOOL' | 'SET_SPECTRUMS_VERTICAL_ALIGN' | 'CHANGE_SPECTRUM_DISPLAY_VIEW_MODE' | 'SET_SPECTRA_SAME_TOP' | 'RESET_SPECTRA_SCALE'> | SetSelectedToolAction | AddBaseLineZoneAction | DeleteBaseLineZoneAction | ResizeBaseLineZoneAction | BrushEndAction | ZoomAction | ZoomOutAction | SetActiveTabAction | LevelChangeAction;
49
51
  declare function handleResetSelectedTool(draft: Draft<State>): void;
50
- declare function resetSelectedTool(draft: Draft<State>, filterOnly?: boolean): void;
52
+ declare function resetSelectedTool(draft: Draft<State>): void;
51
53
  interface ActivateToolOptions {
52
- toolId: string;
54
+ toolId: Tool;
53
55
  reset?: boolean;
54
56
  }
55
- declare function activateTool(draft: any, options: ActivateToolOptions): void;
57
+ declare function activateTool(draft: Draft<State>, options: ActivateToolOptions): void;
56
58
  declare function setSelectedTool(draft: Draft<State>, action: SetSelectedToolAction): void;
57
59
  declare function setSpectrumsVerticalAlign(draft: Draft<State>): void;
58
60
  declare function handleChangeSpectrumDisplayMode(draft: Draft<State>): void;
59
61
  declare function handleAddBaseLineZone(draft: Draft<State>, action: AddBaseLineZoneAction): void;
62
+ declare function handleResizeBaseLineZone(draft: Draft<State>, action: ResizeBaseLineZoneAction): void;
60
63
  declare function handleDeleteBaseLineZone(draft: Draft<State>, action: DeleteBaseLineZoneAction): void;
61
64
  declare function handleToggleRealImaginaryVisibility(draft: Draft<State>): void;
62
65
  declare function handleBrushEnd(draft: Draft<State>, action: BrushEndAction): void;
@@ -69,4 +72,4 @@ declare function handelSetActiveTab(draft: Draft<State>, action: SetActiveTabAct
69
72
  declare function levelChangeHandler(draft: Draft<State>, action: LevelChangeAction): void;
70
73
  declare function setSpectraSameTopHandler(draft: Draft<State>): void;
71
74
  declare function resetSpectraScale(draft: Draft<State>): void;
72
- export { handleResetSelectedTool, resetSelectedTool, setSelectedTool, activateTool, setSpectrumsVerticalAlign, handleChangeSpectrumDisplayMode, handleAddBaseLineZone, handleDeleteBaseLineZone, handleToggleRealImaginaryVisibility, handleBrushEnd, handleZoom, zoomOut, handelSetActiveTab, levelChangeHandler, setActiveTab, setTab, setSpectraSameTopHandler, resetSpectraScale, setMargin, };
75
+ export { handleResetSelectedTool, resetSelectedTool, setSelectedTool, activateTool, setSpectrumsVerticalAlign, handleChangeSpectrumDisplayMode, handleAddBaseLineZone, handleDeleteBaseLineZone, handleResizeBaseLineZone, handleToggleRealImaginaryVisibility, handleBrushEnd, handleZoom, zoomOut, handelSetActiveTab, levelChangeHandler, setActiveTab, setTab, setSpectraSameTopHandler, resetSpectraScale, setMargin, };
@@ -1,5 +1,4 @@
1
1
  import { v4 } from '@lukeed/uuid';
2
- import { original } from 'immer';
3
2
  import { contoursManager } from '../../../data/data2d/Spectrum2D/contours';
4
3
  import { getYScale, getXScale } from '../../1d/utilities/scale';
5
4
  import { LAYOUT } from '../../2d/utilities/DimensionLayout';
@@ -18,10 +17,10 @@ import { getVerticalAlign } from '../helper/getVerticalAlign';
18
17
  import { setIntegralsViewProperty } from '../helper/setIntegralsViewProperty';
19
18
  import { setRangesViewProperty } from '../helper/setRangesViewProperty';
20
19
  import { setDomain, setMode } from './DomainActions';
21
- import { calculateBaseLineCorrection, rollbackSpectrumByFilter, rollbackSpectrum, } from './FiltersActions';
20
+ import { calculateBaseLineCorrection, rollbackSpectrum, } from './FiltersActions';
22
21
  import { changeSpectrumVerticalAlignment } from './PreferencesActions';
23
22
  function resetTool(draft, options = {}) {
24
- const { resetToDefaultTool = true, resetFiltersOptionPanel = true, defaultToolId = 'zoom', resetSpectrum = false, } = options;
23
+ const { resetToDefaultTool = true, resetFiltersOptionPanel = true, defaultToolId = 'zoom', reset, toolId, } = options;
25
24
  // reset temp range
26
25
  if (resetFiltersOptionPanel) {
27
26
  draft.toolOptions.selectedOptionPanel = null;
@@ -29,58 +28,58 @@ function resetTool(draft, options = {}) {
29
28
  if (resetToDefaultTool) {
30
29
  draft.toolOptions.selectedTool = defaultToolId;
31
30
  }
32
- if ((draft.toolOptions.data.activeFilterID || draft.tempData) &&
33
- resetSpectrum) {
34
- rollbackSpectrumByFilter(draft, { reset: true });
31
+ let rollOptions = { reset: true };
32
+ if (toolId && Tools?.[toolId]?.isFilter) {
33
+ rollOptions = { filterKey: toolId, reset };
35
34
  }
35
+ rollbackSpectrum(draft, rollOptions);
36
36
  }
37
37
  function handleResetSelectedTool(draft) {
38
38
  resetSelectedTool(draft);
39
39
  }
40
- function resetSelectedTool(draft, filterOnly = false) {
41
- if ((draft.toolOptions.selectedTool &&
42
- Tools[draft.toolOptions.selectedTool].isFilter) ||
43
- !filterOnly) {
44
- resetTool(draft, { resetSpectrum: true });
40
+ function resetSelectedTool(draft) {
41
+ if (draft.toolOptions.selectedTool &&
42
+ Tools[draft.toolOptions.selectedTool].isFilter) {
43
+ resetTool(draft, { reset: true, toolId: draft.toolOptions.selectedTool });
45
44
  }
46
45
  }
47
46
  //utility
48
47
  function activateTool(draft, options) {
49
48
  const { toolId, reset = false } = options;
50
- if (draft?.data.length > 0) {
51
- if (toolId) {
52
- // start Range edit mode
53
- if (toolId === Tools.editRange.id) {
54
- const activeSpectrum = getActiveSpectrum(draft);
55
- if (activeSpectrum) {
56
- const range = draft.view.ranges?.[activeSpectrum?.id];
57
- if (range) {
58
- range.showMultiplicityTrees = true;
59
- }
60
- else {
61
- draft.view.ranges[activeSpectrum.id] = {
62
- ...defaultRangesViewState,
63
- showMultiplicityTrees: true,
64
- };
65
- }
66
- }
67
- }
68
- if (toolId !== draft.toolOptions.selectedTool) {
69
- resetTool(draft, { resetToDefaultTool: false });
70
- }
71
- draft.toolOptions.selectedTool = toolId;
72
- if (Tools[toolId]?.hasOptionPanel) {
73
- draft.toolOptions.selectedOptionPanel = toolId;
49
+ if (draft?.data.length === 0) {
50
+ return;
51
+ }
52
+ if (!toolId || toolId !== draft.toolOptions.selectedTool || reset) {
53
+ resetTool(draft, { resetToDefaultTool: false, toolId, reset });
54
+ }
55
+ if (!toolId || reset) {
56
+ draft.toolOptions.selectedOptionPanel = null;
57
+ draft.toolOptions.selectedTool = 'zoom';
58
+ draft.toolOptions.data.activeFilterID = null;
59
+ }
60
+ else {
61
+ draft.toolOptions.selectedTool = toolId;
62
+ if (Tools[toolId]?.hasOptionPanel) {
63
+ draft.toolOptions.selectedOptionPanel = toolId;
64
+ }
65
+ }
66
+ // start Range edit mode
67
+ if (toolId === Tools.editRange.id) {
68
+ const activeSpectrum = getActiveSpectrum(draft);
69
+ if (activeSpectrum) {
70
+ const range = draft.view.ranges?.[activeSpectrum?.id];
71
+ if (range) {
72
+ range.showMultiplicityTrees = true;
74
73
  }
75
- if (Tools?.[toolId]?.isFilter) {
76
- rollbackSpectrum(draft, { filterKey: toolId, reset });
74
+ else {
75
+ draft.view.ranges[activeSpectrum.id] = {
76
+ ...defaultRangesViewState,
77
+ showMultiplicityTrees: true,
78
+ };
77
79
  }
78
80
  }
79
- else {
80
- resetTool(draft, { resetToDefaultTool: false });
81
- }
82
- setMargin(draft);
83
81
  }
82
+ setMargin(draft);
84
83
  }
85
84
  function setSelectedTool(draft, action) {
86
85
  const { selectedTool } = action.payload;
@@ -128,11 +127,19 @@ function handleAddBaseLineZone(draft, action) {
128
127
  draft.toolOptions.data.baselineCorrection.zones = zones.slice();
129
128
  calculateBaseLineCorrection(draft);
130
129
  }
130
+ function handleResizeBaseLineZone(draft, action) {
131
+ const { from, to, id } = action.payload;
132
+ const zones = draft.toolOptions.data.baselineCorrection.zones;
133
+ const zoneIndex = zones.findIndex((zone) => zone.id === id);
134
+ if (zoneIndex !== -1) {
135
+ zones[zoneIndex] = { id, from, to };
136
+ }
137
+ calculateBaseLineCorrection(draft);
138
+ }
131
139
  function handleDeleteBaseLineZone(draft, action) {
132
140
  const { id } = action.payload;
133
- const state = original(draft);
134
141
  draft.toolOptions.data.baselineCorrection.zones =
135
- state.toolOptions.data.baselineCorrection.zones.filter((zone) => zone.id !== id);
142
+ draft.toolOptions.data.baselineCorrection.zones.filter((zone) => zone.id !== id);
136
143
  calculateBaseLineCorrection(draft);
137
144
  }
138
145
  function handleToggleRealImaginaryVisibility(draft) {
@@ -437,4 +444,4 @@ function resetSpectraScale(draft) {
437
444
  draft.yDomain = draft.originDomain.yDomain;
438
445
  setZoom(draft, { scale: 0.8 });
439
446
  }
440
- export { handleResetSelectedTool, resetSelectedTool, setSelectedTool, activateTool, setSpectrumsVerticalAlign, handleChangeSpectrumDisplayMode, handleAddBaseLineZone, handleDeleteBaseLineZone, handleToggleRealImaginaryVisibility, handleBrushEnd, handleZoom, zoomOut, handelSetActiveTab, levelChangeHandler, setActiveTab, setTab, setSpectraSameTopHandler, resetSpectraScale, setMargin, };
447
+ export { handleResetSelectedTool, resetSelectedTool, setSelectedTool, activateTool, setSpectrumsVerticalAlign, handleChangeSpectrumDisplayMode, handleAddBaseLineZone, handleDeleteBaseLineZone, handleResizeBaseLineZone, handleToggleRealImaginaryVisibility, handleBrushEnd, handleZoom, zoomOut, handelSetActiveTab, levelChangeHandler, setActiveTab, setTab, setSpectraSameTopHandler, resetSpectraScale, setMargin, };