nmrium 0.53.0 → 0.54.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 (86) hide show
  1. package/lib/component/1d/Viewer1D.js +48 -17
  2. package/lib/component/1d/ranges/Range.js +14 -6
  3. package/lib/component/1d/tool/XLabelPointer.js +4 -12
  4. package/lib/component/2d/tools/XYLabelPointer.js +3 -9
  5. package/lib/component/context/LoggerContext.js +11 -4
  6. package/lib/component/elements/CloseButton.d.ts +1 -1
  7. package/lib/component/elements/CustomToolTip.d.ts +8 -0
  8. package/lib/component/elements/CustomToolTip.js +107 -0
  9. package/lib/component/elements/EditableColumn.js +3 -2
  10. package/lib/component/elements/SaveButton.d.ts +1 -1
  11. package/lib/component/elements/formik/FormikError.js +2 -4
  12. package/lib/component/elements/formik/FormikInput.js +2 -2
  13. package/lib/component/header/Header.js +1 -1
  14. package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.js +41 -10
  15. package/lib/component/main/NMRiumStateProvider.js +11 -1
  16. package/lib/component/modal/AboutPredictionModal.js +1 -1
  17. package/lib/component/modal/AboutSpectrumSimulationModal.js +1 -1
  18. package/lib/component/modal/CopyClipboardModal.js +1 -1
  19. package/lib/component/modal/EditPeakShapeModal.js +1 -1
  20. package/lib/component/modal/ImportPublicationStringModal.js +11 -5
  21. package/lib/component/modal/PredictSpectraModal.js +1 -1
  22. package/lib/component/modal/aboutUs/AboutUsModal.js +1 -1
  23. package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
  24. package/lib/component/modal/editRange/EditRangeModal.js +1 -1
  25. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +1 -1
  26. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +1 -1
  27. package/lib/component/modal/editZone/EditZoneModal.js +1 -1
  28. package/lib/component/modal/setting/GeneralSettings.js +12 -19
  29. package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +2 -2
  30. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +2 -2
  31. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +2 -2
  32. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +1 -1
  33. package/lib/component/panels/PeaksPanel/PeaksPanel.js +5 -5
  34. package/lib/component/panels/RangesPanel/RangesHeader.js +11 -11
  35. package/lib/component/panels/RangesPanel/RangesPreferences.js +16 -16
  36. package/lib/component/panels/RangesPanel/RangesTable.js +1 -1
  37. package/lib/component/panels/RangesPanel/RangesTableRow.js +2 -2
  38. package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +22 -8
  39. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +1 -1
  40. package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.d.ts +5 -5
  41. package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.js +79 -89
  42. package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.d.ts +5 -4
  43. package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.js +66 -98
  44. package/lib/component/panels/SummaryPanel/SummaryPanel.js +13 -32
  45. package/lib/component/panels/ZonesPanel/ZonesPanel.js +4 -4
  46. package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +2 -2
  47. package/lib/component/panels/header/DefaultPanelHeader.js +2 -2
  48. package/lib/component/panels/header/PreferencesHeader.js +1 -1
  49. package/lib/component/panels/header/SpectraAutomaticPickingButton.js +1 -1
  50. package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +4 -4
  51. package/lib/component/reducer/Reducer.js +2 -0
  52. package/lib/component/reducer/actions/FiltersActions.d.ts +3 -2
  53. package/lib/component/reducer/actions/FiltersActions.js +27 -1
  54. package/lib/component/reducer/actions/MoleculeActions.js +1 -1
  55. package/lib/component/reducer/actions/RangesActions.d.ts +2 -3
  56. package/lib/component/reducer/actions/RangesActions.js +16 -20
  57. package/lib/component/reducer/actions/SpectraActions.d.ts +5 -4
  58. package/lib/component/reducer/actions/SpectraActions.js +5 -1
  59. package/lib/component/reducer/preferences/actions/setWorkspace.js +4 -3
  60. package/lib/component/toolbar/ToolBar.js +111 -25
  61. package/lib/component/workspaces/workspaceDefaultProperties.js +7 -12
  62. package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +10 -3
  63. package/lib/data/data1d/Spectrum1D/get1DColor.js +28 -2
  64. package/lib/data/data1d/Spectrum1D/index.d.ts +2 -2
  65. package/lib/data/data1d/Spectrum1D/index.js +2 -2
  66. package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +50 -0
  67. package/lib/data/data1d/Spectrum1D/ranges/createRange.js +51 -0
  68. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +2 -1
  69. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +4 -2
  70. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +52 -0
  71. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.js +28 -0
  72. package/lib/data/data2d/Spectrum2D/get2DColor.d.ts +11 -3
  73. package/lib/data/data2d/Spectrum2D/get2DColor.js +20 -4
  74. package/lib/data/data2d/Spectrum2D/getSlice.js +1 -1
  75. package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts +1 -0
  76. package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts +1 -0
  77. package/lib/data/utilities/generateColor.d.ts +7 -3
  78. package/lib/data/utilities/generateColor.js +5 -17
  79. package/lib/versionInfo.js +1 -1
  80. package/package.json +20 -20
  81. package/lib/component/elements/MolecularFormulaInput.d.ts +0 -6
  82. package/lib/component/elements/MolecularFormulaInput.js +0 -63
  83. package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +0 -7
  84. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +0 -31
  85. package/lib/data/data1d/Spectrum1D/ranges/changeRange.d.ts +0 -3
  86. package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +0 -32
@@ -61,7 +61,7 @@ function MultipleSpectraAnalysisPanelInner({ activeTab, spectra, showLegend, dis
61
61
  let lefButtons = [
62
62
  {
63
63
  icon: _jsx(FaFileExport, {}),
64
- title: 'Copy to clipboard',
64
+ tooltip: 'Copy to clipboard',
65
65
  onClick: copyToClipboardHandler,
66
66
  },
67
67
  ];
@@ -69,19 +69,19 @@ function MultipleSpectraAnalysisPanelInner({ activeTab, spectra, showLegend, dis
69
69
  lefButtons = lefButtons.concat([
70
70
  {
71
71
  icon: _jsx(SvgNmrOverlay, {}),
72
- title: 'Spectra calibration',
72
+ tooltip: 'Spectra calibration',
73
73
  onClick: handleSpectraCalibration,
74
74
  active: calibration,
75
75
  },
76
76
  {
77
77
  icon: _jsx(IoPulseOutline, {}),
78
- title: 'Y spectra tracker',
78
+ tooltip: 'Y spectra tracker',
79
79
  onClick: showTrackerHandler,
80
80
  active: showLegend,
81
81
  },
82
82
  {
83
83
  icon: _jsx(FaChartBar, {}),
84
- title: `${booleanToString(!showAnalysisChart)} analysis chart`,
84
+ tooltip: `${booleanToString(!showAnalysisChart)} analysis chart`,
85
85
  onClick: toggleAnalysisChart,
86
86
  active: showAnalysisChart,
87
87
  },
@@ -246,6 +246,8 @@ function innerSpectrumReducer(draft, action) {
246
246
  return FiltersActions.handleCalculateManualTwoDimensionPhaseCorrection(draft, action);
247
247
  case 'APPLY_MANUAL_PHASE_CORRECTION_TOW_DIMENSION_FILTER':
248
248
  return FiltersActions.handleApplyManualTowDimensionsPhaseCorrectionFilter(draft);
249
+ case 'APPLY_AUTO_PHASE_CORRECTION_TOW_DIMENSION_FILTER':
250
+ return FiltersActions.handleApplyAutoPhaseCorrectionTwoDimensionsFilter(draft);
249
251
  case 'CHANGE_SPECTRUM_VISIBILITY':
250
252
  return SpectraActions.handleChangeSpectrumVisibilityById(draft, action);
251
253
  case 'CHANGE_SPECTRA_VISIBILITY_BY_NUCLEUS':
@@ -86,7 +86,7 @@ type SetTwoDimensionPhaseCorrectionPivotPoint = ActionType<'SET_TWO_DIMENSION_PI
86
86
  x: number;
87
87
  y: number;
88
88
  }>;
89
- export type FiltersActions = ShiftSpectrumAlongXAxisAction | ApodizationFilterAction | ApodizationFilterLiveAction | ZeroFillingFilterAction | ZeroFillingFilterLiveAction | ManualPhaseCorrectionFilterAction | BaselineCorrectionFilterAction | BaselineCorrectionFilterLiveAction | EnableFilterAction | DeleteFilterAction | DeleteSpectraFilterAction | SetFilterSnapshotAction | AddExclusionZoneAction | DeleteExclusionZoneAction | ApplySignalProcessingAction | AddPhaseCorrectionTraceAction | ChangePhaseCorrectionDirectionAction | DeletePhaseCorrectionTrace | SetOneDimensionPhaseCorrectionPivotPoint | SetTwoDimensionPhaseCorrectionPivotPoint | ManualTwoDimensionsPhaseCorrectionFilterAction | ActionType<'APPLY_FFT_FILTER' | 'APPLY_FFT_DIMENSION_1_FILTER' | 'APPLY_FFT_DIMENSION_2_FILTER' | 'APPLY_AUTO_PHASE_CORRECTION_FILTER' | 'APPLY_ABSOLUTE_FILTER' | 'APPLY_MANUAL_PHASE_CORRECTION_TOW_DIMENSION_FILTER' | 'TOGGLE_ADD_PHASE_CORRECTION_TRACE_TO_BOTH_DIRECTIONS'>;
89
+ export type FiltersActions = ShiftSpectrumAlongXAxisAction | ApodizationFilterAction | ApodizationFilterLiveAction | ZeroFillingFilterAction | ZeroFillingFilterLiveAction | ManualPhaseCorrectionFilterAction | BaselineCorrectionFilterAction | BaselineCorrectionFilterLiveAction | EnableFilterAction | DeleteFilterAction | DeleteSpectraFilterAction | SetFilterSnapshotAction | AddExclusionZoneAction | DeleteExclusionZoneAction | ApplySignalProcessingAction | AddPhaseCorrectionTraceAction | ChangePhaseCorrectionDirectionAction | DeletePhaseCorrectionTrace | SetOneDimensionPhaseCorrectionPivotPoint | SetTwoDimensionPhaseCorrectionPivotPoint | ManualTwoDimensionsPhaseCorrectionFilterAction | ActionType<'APPLY_FFT_FILTER' | 'APPLY_FFT_DIMENSION_1_FILTER' | 'APPLY_FFT_DIMENSION_2_FILTER' | 'APPLY_AUTO_PHASE_CORRECTION_FILTER' | 'APPLY_ABSOLUTE_FILTER' | 'APPLY_MANUAL_PHASE_CORRECTION_TOW_DIMENSION_FILTER' | 'TOGGLE_ADD_PHASE_CORRECTION_TRACE_TO_BOTH_DIRECTIONS' | 'APPLY_AUTO_PHASE_CORRECTION_TOW_DIMENSION_FILTER'>;
90
90
  export interface RollbackSpectrumByFilterOptions {
91
91
  applyFilter?: boolean;
92
92
  reset?: boolean;
@@ -131,4 +131,5 @@ declare function handleSetOneDimensionPhaseCorrectionPivotPoint(draft: Draft<Sta
131
131
  declare function handleSetTwoDimensionPhaseCorrectionPivotPoint(draft: Draft<State>, action: SetTwoDimensionPhaseCorrectionPivotPoint): void;
132
132
  declare function handleCalculateManualTwoDimensionPhaseCorrection(draft: Draft<State>, action: ManualTwoDimensionsPhaseCorrectionFilterAction): void;
133
133
  declare function handleApplyManualTowDimensionsPhaseCorrectionFilter(draft: Draft<State>): void;
134
- export { handleShiftSpectrumAlongXAxis, handleApplyZeroFillingFilter, handleApplyApodizationFilter, handleApplyFFTFilter, handleApplyFFtDimension1Filter, handleApplyFFtDimension2Filter, handleApplyManualPhaseCorrectionFilter, handleApplyManualTowDimensionsPhaseCorrectionFilter, handleApplyAutoPhaseCorrectionFilter, handleApplyAbsoluteFilter, handleCalculateManualPhaseCorrection, calculateBaseLineCorrection, handleCalculateBaseLineCorrection, handleCalculateApodizationFilter, handleCalculateZeroFillingFilter, handleEnableFilter, handleDeleteFilter, handleDeleteSpectraFilter, handleBaseLineCorrectionFilter, handleSetFilterSnapshotHandler, handleAddExclusionZone, handleDeleteExclusionZone, handleSignalProcessingFilter, rollbackSpectrum, rollbackSpectrumByFilter, handleAddPhaseCorrectionTrace, handleChangePhaseCorrectionDirection, handleDeletePhaseCorrectionTrace, handleSetOneDimensionPhaseCorrectionPivotPoint, handleSetTwoDimensionPhaseCorrectionPivotPoint, handleCalculateManualTwoDimensionPhaseCorrection, handleToggleAddTracesToBothDirections, };
134
+ declare function handleApplyAutoPhaseCorrectionTwoDimensionsFilter(draft: Draft<State>): void;
135
+ export { handleShiftSpectrumAlongXAxis, handleApplyZeroFillingFilter, handleApplyApodizationFilter, handleApplyFFTFilter, handleApplyFFtDimension1Filter, handleApplyFFtDimension2Filter, handleApplyManualPhaseCorrectionFilter, handleApplyManualTowDimensionsPhaseCorrectionFilter, handleApplyAutoPhaseCorrectionFilter, handleApplyAbsoluteFilter, handleCalculateManualPhaseCorrection, calculateBaseLineCorrection, handleCalculateBaseLineCorrection, handleCalculateApodizationFilter, handleCalculateZeroFillingFilter, handleEnableFilter, handleDeleteFilter, handleDeleteSpectraFilter, handleBaseLineCorrectionFilter, handleSetFilterSnapshotHandler, handleAddExclusionZone, handleDeleteExclusionZone, handleSignalProcessingFilter, rollbackSpectrum, rollbackSpectrumByFilter, handleAddPhaseCorrectionTrace, handleChangePhaseCorrectionDirection, handleDeletePhaseCorrectionTrace, handleSetOneDimensionPhaseCorrectionPivotPoint, handleSetTwoDimensionPhaseCorrectionPivotPoint, handleCalculateManualTwoDimensionPhaseCorrection, handleToggleAddTracesToBothDirections, handleApplyAutoPhaseCorrectionTwoDimensionsFilter, };
@@ -963,4 +963,30 @@ function handleApplyManualTowDimensionsPhaseCorrectionFilter(draft) {
963
963
  updateView(draft, phaseCorrectionTwoDimensions.DOMAIN_UPDATE_RULES);
964
964
  }
965
965
  }
966
- export { handleShiftSpectrumAlongXAxis, handleApplyZeroFillingFilter, handleApplyApodizationFilter, handleApplyFFTFilter, handleApplyFFtDimension1Filter, handleApplyFFtDimension2Filter, handleApplyManualPhaseCorrectionFilter, handleApplyManualTowDimensionsPhaseCorrectionFilter, handleApplyAutoPhaseCorrectionFilter, handleApplyAbsoluteFilter, handleCalculateManualPhaseCorrection, calculateBaseLineCorrection, handleCalculateBaseLineCorrection, handleCalculateApodizationFilter, handleCalculateZeroFillingFilter, handleEnableFilter, handleDeleteFilter, handleDeleteSpectraFilter, handleBaseLineCorrectionFilter, handleSetFilterSnapshotHandler, handleAddExclusionZone, handleDeleteExclusionZone, handleSignalProcessingFilter, rollbackSpectrum, rollbackSpectrumByFilter, handleAddPhaseCorrectionTrace, handleChangePhaseCorrectionDirection, handleDeletePhaseCorrectionTrace, handleSetOneDimensionPhaseCorrectionPivotPoint, handleSetTwoDimensionPhaseCorrectionPivotPoint, handleCalculateManualTwoDimensionPhaseCorrection, handleToggleAddTracesToBothDirections, };
966
+ //action
967
+ function handleApplyAutoPhaseCorrectionTwoDimensionsFilter(draft) {
968
+ const activeSpectrum = getActiveSpectrum(draft);
969
+ if (!activeSpectrum || !draft.tempData) {
970
+ return;
971
+ }
972
+ const { index } = activeSpectrum;
973
+ const activeFilterIndex = getActiveFilterIndex(draft);
974
+ FiltersManager.applyFilter(draft.tempData[index], [
975
+ {
976
+ name: phaseCorrectionTwoDimensions.id,
977
+ value: {},
978
+ },
979
+ ], { filterIndex: activeFilterIndex });
980
+ draft.data[index] = draft.tempData[index];
981
+ if (activeFilterIndex !== -1) {
982
+ rollbackSpectrumByFilter(draft, {
983
+ searchBy: 'name',
984
+ key: phaseCorrectionTwoDimensions.id,
985
+ triggerSource: 'Apply',
986
+ });
987
+ }
988
+ else {
989
+ updateView(draft, phaseCorrectionTwoDimensions.DOMAIN_UPDATE_RULES);
990
+ }
991
+ }
992
+ export { handleShiftSpectrumAlongXAxis, handleApplyZeroFillingFilter, handleApplyApodizationFilter, handleApplyFFTFilter, handleApplyFFtDimension1Filter, handleApplyFFtDimension2Filter, handleApplyManualPhaseCorrectionFilter, handleApplyManualTowDimensionsPhaseCorrectionFilter, handleApplyAutoPhaseCorrectionFilter, handleApplyAbsoluteFilter, handleCalculateManualPhaseCorrection, calculateBaseLineCorrection, handleCalculateBaseLineCorrection, handleCalculateApodizationFilter, handleCalculateZeroFillingFilter, handleEnableFilter, handleDeleteFilter, handleDeleteSpectraFilter, handleBaseLineCorrectionFilter, handleSetFilterSnapshotHandler, handleAddExclusionZone, handleDeleteExclusionZone, handleSignalProcessingFilter, rollbackSpectrum, rollbackSpectrumByFilter, handleAddPhaseCorrectionTrace, handleChangePhaseCorrectionDirection, handleDeletePhaseCorrectionTrace, handleSetOneDimensionPhaseCorrectionPivotPoint, handleSetTwoDimensionPhaseCorrectionPivotPoint, handleCalculateManualTwoDimensionPhaseCorrection, handleToggleAddTracesToBothDirections, handleApplyAutoPhaseCorrectionTwoDimensionsFilter, };
@@ -86,7 +86,7 @@ function handleDeleteMolecule(draft, action) {
86
86
  function handlePredictSpectraFromMolecule(draft, action) {
87
87
  const { logger, predictedSpectra, options, molecule, action: predictionAction = 'save', } = action.payload;
88
88
  checkPredictions(predictedSpectra, options, molecule.molfile, logger);
89
- const color = generateColor(false, draft.usedColors['1d']);
89
+ const color = generateColor({ usedColors: draft.usedColors['1d'] });
90
90
  const spectraIds = [];
91
91
  for (const spectrum of generateSpectra(predictedSpectra, options, color, logger)) {
92
92
  draft.data.push(spectrum);
@@ -49,8 +49,7 @@ type ChangeRangeSumAction = ActionType<'CHANGE_RANGE_SUM', {
49
49
  options: SetSumOptions;
50
50
  }>;
51
51
  type AddRangeAction = ActionType<'ADD_RANGE', {
52
- startX: number;
53
- endX: number;
52
+ range: Range;
54
53
  }>;
55
54
  type ChangeRangeRelativeValueAction = ActionType<'CHANGE_RANGE_RELATIVE', ChangeRangeRelativeValueProps>;
56
55
  type ChangeRangeSignalValueAction = ActionType<'CHANGE_RANGE_SIGNAL_VALUE', {
@@ -62,7 +61,7 @@ type UpdateRangAction = ActionType<'UPDATE_RANGE', {
62
61
  range: Range;
63
62
  }>;
64
63
  type CutRangAction = ActionType<'CUT_RANGE', {
65
- cutValue: number;
64
+ ranges: Record<string, Range[]>;
66
65
  }>;
67
66
  type ToggleRangesViewAction = ActionType<'TOGGLE_RANGES_VIEW_PROPERTY', {
68
67
  key: keyof FilterType<RangesViewState, boolean>;
@@ -4,11 +4,10 @@ import cloneDeep from 'lodash/cloneDeep';
4
4
  import { xFindClosestIndex } from 'ml-spectra-processing';
5
5
  import { Filters, FiltersManager } from 'nmr-processing';
6
6
  import { DATUM_KIND, SIGNAL_INLCUDED_KINDS, } from '../../../data/constants/signalsKinds';
7
- import { addRange, changeRangeSignal, detectRanges, updateRangesRelativeValues, changeRange, changeRangeRelativeValue, isSpectrum1D, } from '../../../data/data1d/Spectrum1D';
7
+ import { changeRangeSignal, detectRanges, updateRangesRelativeValues, changeRangeRelativeValue, isSpectrum1D, } from '../../../data/data1d/Spectrum1D';
8
8
  import { initSumOptions, setSumOptions, } from '../../../data/data1d/Spectrum1D/SumManager';
9
9
  import { unlink, unlinkInAssignmentData, } from '../../../data/utilities/RangeUtilities';
10
10
  import { getActiveSpectrum } from '../helper/getActiveSpectrum';
11
- import getRange from '../helper/getRange';
12
11
  import { getSpectrum } from '../helper/getSpectrum';
13
12
  import { setRangesViewProperty } from '../helper/setRangesViewProperty';
14
13
  import { handleUpdateCorrelations } from './CorrelationsActions';
@@ -232,12 +231,15 @@ function handleSetDiaIDRange(draft, action) {
232
231
  }
233
232
  //action
234
233
  function handleResizeRange(draft, action) {
235
- const activeSpectrum = getActiveSpectrum(draft);
236
- if (activeSpectrum?.id) {
237
- const { index } = activeSpectrum;
238
- const { range } = action.payload;
239
- changeRange(draft.data[index], range);
240
- }
234
+ const spectrum = getSpectrum(draft);
235
+ if (!spectrum)
236
+ return;
237
+ const { range } = action.payload;
238
+ if (!range && !isSpectrum1D(spectrum))
239
+ return;
240
+ const index = spectrum.ranges.values.findIndex((i) => i.id === range.id);
241
+ spectrum.ranges.values[index] = range;
242
+ updateRangesRelativeValues(spectrum);
241
243
  }
242
244
  //action
243
245
  function handleChangeRangeSum(draft, action) {
@@ -260,18 +262,13 @@ function initiateRangeSumOptions(datum, options) {
260
262
  }
261
263
  //action
262
264
  function handleAddRange(draft, action) {
263
- const { startX, endX } = action.payload;
264
- const range = getRange(draft, { startX, endX });
265
+ const { range } = action.payload;
265
266
  const { data, view: { spectra: { activeTab: nucleus }, }, molecules, } = draft;
266
267
  const activeSpectrum = getActiveSpectrum(draft);
267
268
  if (activeSpectrum?.id) {
268
269
  const { index } = activeSpectrum;
269
- const [from, to] = range;
270
270
  const datum = data[index];
271
- addRange(datum, {
272
- from,
273
- to,
274
- });
271
+ datum.ranges.values.push(range);
275
272
  initiateRangeSumOptions(datum, {
276
273
  nucleus,
277
274
  molecules,
@@ -335,15 +332,14 @@ function handleToggleRangesViewProperty(draft, action) {
335
332
  toggleRangesViewProperty(draft, key);
336
333
  }
337
334
  function handleCutRange(draft, action) {
338
- const { cutValue } = action.payload;
335
+ const { ranges: cutRanges } = action.payload;
339
336
  const spectrum = getSpectrum(draft);
340
337
  const ranges = spectrum.ranges.values;
341
338
  for (let i = 0; i < ranges.length; i++) {
342
- const { to, from } = ranges[i];
343
- if (cutValue > from && cutValue < to) {
339
+ const { id } = ranges[i];
340
+ if (cutRanges?.[id]) {
344
341
  ranges.splice(i, 1);
345
- addRange(spectrum, { from, to: cutValue });
346
- addRange(spectrum, { from: cutValue, to });
342
+ ranges.push(...cutRanges[id]);
347
343
  }
348
344
  }
349
345
  updateRangesRelativeValues(spectrum);
@@ -1,5 +1,5 @@
1
1
  import { Draft } from 'immer';
2
- import { Spectrum, Display1D, Display2D } from 'nmr-load-save';
2
+ import { Spectrum, Display1D, Display2D, SpectraColors } from 'nmr-load-save';
3
3
  import { NMRRange } from 'nmr-processing';
4
4
  import { SpectrumSimulationOptions } from '../../../data/data1d/spectrumSimulation';
5
5
  import { Nuclei, Nucleus } from '../../../data/types/common/Nucleus';
@@ -45,8 +45,9 @@ type GenerateSpectrumFromPublicationStringAction = ActionType<'GENERATE_SPECTRUM
45
45
  type ImportSpectraMetaInfoAction = ActionType<'IMPORT_SPECTRA_META_INFO', {
46
46
  spectraMeta: Record<string, Record<string, any>>;
47
47
  }>;
48
- type RecolorSpectraBasedOnDistinctValueAction = ActionType<'RECOLOR_SPECTRA_COLOR', {
48
+ type ReColorSpectraBasedOnDistinctValueAction = ActionType<'RECOLOR_SPECTRA_COLOR', {
49
49
  jpath?: string[];
50
+ customColors?: SpectraColors;
50
51
  }>;
51
52
  type OrderSpectraAction = ActionType<'ORDER_SPECTRA', {
52
53
  data: Spectrum[];
@@ -55,7 +56,7 @@ type SimulateSpectrumAction = ActionType<'SIMULATE_SPECTRUM', {
55
56
  keepSpectrum?: boolean;
56
57
  spinSystem: string;
57
58
  } & SpectrumSimulationOptions>;
58
- export type SpectrumActions = ActionType<'TOGGLE_SPECTRA_LEGEND'> | ChangeSpectrumVisibilityByIdAction | ChangeSpectraVisibilityByNucleusAction | ChangeActiveSpectrumAction | ChangeSpectrumSettingAction | DeleteSpectraAction | AddMissingProjectionAction | AlignSpectraAction | GenerateSpectrumFromPublicationStringAction | ImportSpectraMetaInfoAction | RecolorSpectraBasedOnDistinctValueAction | OrderSpectraAction | SimulateSpectrumAction;
59
+ export type SpectrumActions = ActionType<'TOGGLE_SPECTRA_LEGEND'> | ChangeSpectrumVisibilityByIdAction | ChangeSpectraVisibilityByNucleusAction | ChangeActiveSpectrumAction | ChangeSpectrumSettingAction | DeleteSpectraAction | AddMissingProjectionAction | AlignSpectraAction | GenerateSpectrumFromPublicationStringAction | ImportSpectraMetaInfoAction | ReColorSpectraBasedOnDistinctValueAction | OrderSpectraAction | SimulateSpectrumAction;
59
60
  declare function setSpectraMetaInfo(draft: Draft<State>, spectraMetaInfo: Record<string, Record<string, any>>): void;
60
61
  declare function handleChangeSpectrumVisibilityById(draft: Draft<State>, action: ChangeSpectrumVisibilityByIdAction): void;
61
62
  declare function handleChangeSpectraVisibilityByNucleus(draft: Draft<State>, action: ChangeSpectraVisibilityByNucleusAction): void;
@@ -67,7 +68,7 @@ declare function handleAlignSpectraHandler(draft: Draft<State>, action: AlignSpe
67
68
  declare function handleGenerateSpectrumFromPublicationStringHandler(draft: Draft<State>, action: GenerateSpectrumFromPublicationStringAction): void;
68
69
  declare function handleImportSpectraMetaInfo(draft: Draft<State>, action: ImportSpectraMetaInfoAction): void;
69
70
  declare function handleToggleSpectraLegend(draft: Draft<State>): void;
70
- declare function handleRecolorSpectraBasedOnDistinctValue(draft: Draft<State>, action: RecolorSpectraBasedOnDistinctValueAction): void;
71
+ declare function handleRecolorSpectraBasedOnDistinctValue(draft: Draft<State>, action: ReColorSpectraBasedOnDistinctValueAction): void;
71
72
  declare function handleOrderSpectra(draft: Draft<State>, action: OrderSpectraAction): void;
72
73
  declare function handleSimulateSpectrum(draft: Draft<State>, simulateSpectrumOptions: SimulateSpectrumAction): void;
73
74
  export { handleChangeSpectrumVisibilityById, handleChangeSpectraVisibilityByNucleus, handleChangeActiveSpectrum, handleChangeSpectrumSetting, handleDeleteSpectra, handleAddMissingProjectionHandler, handleAlignSpectraHandler, handleGenerateSpectrumFromPublicationStringHandler, handleImportSpectraMetaInfo, handleToggleSpectraLegend, handleRecolorSpectraBasedOnDistinctValue, handleOrderSpectra, handleSimulateSpectrum, setSpectraMetaInfo, };
@@ -320,7 +320,7 @@ function handleToggleSpectraLegend(draft) {
320
320
  //action
321
321
  function handleRecolorSpectraBasedOnDistinctValue(draft, action) {
322
322
  const { data, view: { spectra: { activeTab }, }, } = draft;
323
- const { jpath = null } = action.payload;
323
+ const { jpath = null, customColors } = action.payload;
324
324
  const spectra = getSpectraByNucleus(activeTab, data);
325
325
  if (jpath) {
326
326
  //recolor spectra based on distinct value
@@ -352,12 +352,16 @@ function handleRecolorSpectraBasedOnDistinctValue(draft, action) {
352
352
  spectrum.display.color = get1DColor(spectrum, {
353
353
  usedColors,
354
354
  regenerate: true,
355
+ random: !customColors,
356
+ colors: customColors?.oneDimension || [],
355
357
  }).color;
356
358
  }
357
359
  else {
358
360
  const { positiveColor, negativeColor } = get2DColor(spectrum, {
359
361
  usedColors,
360
362
  regenerate: true,
363
+ random: !customColors,
364
+ colors: customColors?.twoDimensions || [],
361
365
  });
362
366
  spectrum.display.positiveColor = positiveColor;
363
367
  spectrum.display.negativeColor = negativeColor;
@@ -11,8 +11,9 @@ export function setWorkspace(draft, action) {
11
11
  }
12
12
  else if (action.payload.workspaceSource === 'nmriumFile') {
13
13
  const workspaceData = { label: 'NMRium File', source: 'nmriumFile' };
14
- draft.workspaces[WORKSPACES_KEYS.nmriumKey] = initWorkspace(action.payload.data, workspaceData);
15
- draft.originalWorkspaces[WORKSPACES_KEYS.nmriumKey] = initWorkspace(action.payload.data, workspaceData);
16
- draft.workspace.current = WORKSPACES_KEYS.nmriumKey;
14
+ const workspaceKey = WORKSPACES_KEYS.nmriumKey;
15
+ draft.workspaces[workspaceKey] = initWorkspace(action.payload.data, workspaceData);
16
+ draft.originalWorkspaces[workspaceKey] = initWorkspace(action.payload.data, workspaceData);
17
+ draft.workspace = { current: workspaceKey, base: workspaceKey };
17
18
  }
18
19
  }
@@ -7,6 +7,7 @@ import { Toolbar } from 'react-science/ui';
7
7
  import { useChartData } from '../context/ChartContext';
8
8
  import { useDispatch } from '../context/DispatchContext';
9
9
  import { useLoader } from '../context/LoaderContext';
10
+ import { CustomToolTip } from '../elements/CustomToolTip';
10
11
  import { ToolbarPopoverItem, } from '../elements/ToolbarPopoverItem';
11
12
  import useCheckExperimentalFeature from '../hooks/useCheckExperimentalFeature';
12
13
  import { useCheckToolsVisibility, } from '../hooks/useCheckToolsVisibility';
@@ -105,143 +106,228 @@ export default function ToolBar() {
105
106
  const toolItems = [
106
107
  {
107
108
  id: 'zoom',
108
- title: options.zoom.label,
109
+ tooltip: {
110
+ title: options.zoom.label,
111
+ subTitles: [
112
+ { title: 'Vertical', shortcuts: ['Scroll wheel'] },
113
+ { title: 'Horizontal', shortcuts: ['Shift', 'Scroll wheel'] },
114
+ { title: 'Pan', shortcuts: ['Right mouse'] },
115
+ ],
116
+ },
109
117
  icon: _jsx(FaSearchPlus, {}),
110
118
  },
111
119
  {
112
120
  id: 'zoomOut',
113
- title: 'Horizontal zoom out (Press f), Horizontal and Vertical zoom out, double click (Press ff)',
121
+ tooltip: {
122
+ title: 'Zoom out',
123
+ subTitles: [
124
+ { title: 'Horizontal', shortcuts: ['f'] },
125
+ { title: 'Horizontal and Vertical', shortcuts: ['f', 'f'] },
126
+ ],
127
+ description: 'You can zoom out by double click on the left mouse button and full zoom out by press key "f" or press key "f" twice to fit the spectra in the window.',
128
+ link: 'https://docs.nmrium.org/help/zoom-and-scale',
129
+ },
114
130
  onClick: handleFullZoomOut,
115
131
  icon: _jsx(FaExpand, {}),
116
132
  },
117
133
  {
118
134
  id: 'peakPicking',
119
- title: `${options.peakPicking.label} (Press p)`,
135
+ tooltip: {
136
+ title: options.peakPicking.label,
137
+ shortcuts: ['p'],
138
+ description: 'You can detect peaks manually or automatically in the spectrum.',
139
+ link: 'https://docs.nmrium.org/20_1d-spectra/peaks/peaks',
140
+ },
120
141
  icon: _jsx(SvgNmrPeakPicking, {}),
121
142
  },
122
143
  {
123
144
  id: 'integral',
124
- title: `${options.integral.label} (Press i)`,
145
+ tooltip: {
146
+ title: options.integral.label,
147
+ shortcuts: ['i'],
148
+ description: 'To calculate the integration, hold Shift and left-click, then drag over the signal range.',
149
+ link: 'https://docs.nmrium.org/help/integrations',
150
+ },
125
151
  icon: _jsx(SvgNmrIntegrate, {}),
126
152
  },
127
153
  {
128
154
  id: 'zonePicking',
129
- title: `${options.zonePicking.label} (Press r)`,
155
+ tooltip: {
156
+ title: options.zonePicking.label,
157
+ shortcuts: ['r'],
158
+ description: 'You can detect zones manually by selecting, holding Shift,left-click, dragging, and then releasing. Alternatively, detect zones automatically.',
159
+ link: 'https://docs.nmrium.org/30_2d-spectra/zones/zones',
160
+ },
130
161
  icon: _jsx(FaDiceFour, {}),
131
162
  },
132
163
  {
133
164
  id: 'slicing',
134
- title: options.slicing.label,
165
+ tooltip: {
166
+ title: options.slicing.label,
167
+ description: 'You can display the shift on the x-axis and the y-axis for each point of a 2D spectrum.',
168
+ link: 'https://docs.nmrium.org/30_2d-spectra/slicing/slicing',
169
+ },
135
170
  icon: _jsx(PiKnifeBold, {}),
136
171
  },
137
172
  {
138
173
  id: 'rangePicking',
139
- title: `${options.rangePicking.label} (Press r)`,
174
+ tooltip: {
175
+ title: options.rangePicking.label,
176
+ shortcuts: ['r'],
177
+ description: 'You can detect ranges manually by selecting, holding Shift,left-click, dragging, and then releasing. Alternatively, detect ranges automatically.',
178
+ link: 'https://docs.nmrium.org/20_1d-spectra/ranges/ranges',
179
+ },
140
180
  icon: _jsx(SvgNmrRangePicking, {}),
141
181
  },
142
182
  {
143
183
  id: 'multipleSpectraAnalysis',
144
- title: options.multipleSpectraAnalysis.label,
184
+ tooltip: options.multipleSpectraAnalysis.label,
145
185
  icon: _jsx(SvgNmrMultipleAnalysis, {}),
146
186
  checkOptions: { checkSpectrumType: false },
147
187
  condition: ftCounter > 0,
148
188
  },
149
189
  {
150
190
  id: 'apodization',
151
- title: `${options.apodization.label} (Press a)`,
191
+ tooltip: {
192
+ title: options.apodization.label,
193
+ shortcuts: ['a'],
194
+ },
152
195
  icon: _jsx(SvgNmrApodization, {}),
153
196
  },
154
197
  {
155
198
  id: 'zeroFilling',
156
- title: `${options.zeroFilling.label} (Press z)`,
199
+ tooltip: {
200
+ title: options.zeroFilling.label,
201
+ shortcuts: ['z'],
202
+ description: 'To improve spectrum quality by increasing the number of points per ppm, by default, the number of points is twice as many points as in the original FID.',
203
+ link: 'https://docs.nmrium.org/20_1d-spectra/preprocessing/preprocessing#zero-filling',
204
+ },
157
205
  icon: _jsx(SvgNmrZeroFilling, {}),
158
206
  },
159
207
  {
160
208
  id: 'phaseCorrection',
161
- title: `${options.phaseCorrection.label} (Press a)`,
209
+ tooltip: {
210
+ title: options.phaseCorrection.label,
211
+ shortcuts: ['a'],
212
+ description: 'To phase the spectrum after the FFT.',
213
+ link: 'https://docs.nmrium.org/20_1d-spectra/phase/phase',
214
+ },
162
215
  icon: _jsx(SvgNmrPhaseCorrection, {}),
163
216
  },
164
217
  {
165
218
  id: 'phaseCorrectionTwoDimensions',
166
- title: `${options.phaseCorrectionTwoDimensions.label} (Press a)`,
219
+ tooltip: {
220
+ title: options.phaseCorrectionTwoDimensions.label,
221
+ shortcuts: ['a'],
222
+ description: 'To phase the spectrum after the FFT.',
223
+ },
167
224
  icon: _jsx(SvgNmrPhaseCorrection, {}),
168
225
  },
169
226
  {
170
227
  id: 'baselineCorrection',
171
- title: `${options.baselineCorrection.label} (Press b)`,
228
+ tooltip: {
229
+ title: options.baselineCorrection.label,
230
+ shortcuts: ['b'],
231
+ description: 'To process the spectrum to be a straight line at zero absorbance.',
232
+ link: 'https://docs.nmrium.org/20_1d-spectra/baseline/baseline',
233
+ },
172
234
  icon: _jsx(SvgNmrBaselineCorrection, {}),
173
235
  },
174
236
  {
175
237
  id: 'exclusionZones',
176
- title: `${options.exclusionZones.label} (Press e)`,
238
+ tooltip: {
239
+ title: options.exclusionZones.label,
240
+ shortcuts: ['e'],
241
+ },
177
242
  icon: _jsx(SvgNmrMultipleAnalysis, {}),
178
243
  checkOptions: { checkSpectrumType: false },
179
244
  condition: ftCounter > 0,
180
245
  },
181
246
  {
182
247
  id: 'fft',
183
- title: `${options.fft.label} (Press t)`,
248
+ tooltip: {
249
+ title: options.fft.label,
250
+ shortcuts: ['t'],
251
+ description: 'To process the FID to FT spectrum.',
252
+ link: 'https://docs.nmrium.org/20_1d-spectra/ft/ft/',
253
+ },
184
254
  onClick: handleOnFFTFilter,
185
255
  icon: _jsx(SvgNmrFourierTransform, {}),
186
256
  },
187
257
  {
188
258
  id: 'fftDimension1',
189
- title: options.fftDimension1.label,
259
+ tooltip: options.fftDimension1.label,
190
260
  onClick: handleFFtDimension1Filter,
191
261
  icon: _jsx(SvgNmrFourierTransform, {}),
192
262
  },
193
263
  {
194
264
  id: 'fftDimension2',
195
- title: options.fftDimension2.label,
265
+ tooltip: options.fftDimension2.label,
196
266
  onClick: handleFFtDimension2Filter,
197
267
  icon: _jsx(SvgNmrFourierTransform, {}),
198
268
  },
199
269
  {
200
270
  id: 'import',
201
- title: options.import.label,
271
+ tooltip: options.import.label,
202
272
  icon: _jsx(FaFileImport, {}),
203
273
  menuItems: importMenu,
204
274
  onClick: importHandler,
205
275
  },
206
276
  {
207
277
  id: 'exportAs',
208
- title: options.exportAs.label,
278
+ tooltip: options.exportAs.label,
209
279
  icon: _jsx(FaFileExport, {}),
210
280
  menuItems: exportMenu,
211
281
  onClick: exportHandler,
212
282
  },
213
283
  {
214
284
  id: 'spectraStackAlignments',
215
- title: `${options.spectraStackAlignments.label} (Press s)`,
285
+ tooltip: {
286
+ title: options.spectraStackAlignments.label,
287
+ shortcuts: ['s'],
288
+ description: 'To display the spectra in a stack mode.',
289
+ },
216
290
  icon: verticalAlign === 'stack' ? (_jsx(SvgNmrOverlay3Aligned, {})) : (_jsx(SvgNmrOverlay3, {})),
217
291
  condition: ftCounter > 1,
218
292
  onClick: changeDisplayViewModeHandler,
219
293
  },
220
294
  {
221
295
  id: 'realImaginary',
222
- title: isRealSpectrumShown ? 'Display real ' : 'Display imaginary',
296
+ tooltip: {
297
+ title: `Display ${isRealSpectrumShown ? 'real' : 'imaginary'}`,
298
+ description: 'To switch between imaginary and real part of the spectrum.',
299
+ link: 'https://docs.nmrium.org/20_1d-spectra/views/views',
300
+ },
223
301
  icon: _jsx(SvgNmrRealImag, {}),
224
302
  onClick: changeSpectrumViewHandler,
225
303
  },
226
304
  {
227
305
  id: 'spectraCenterAlignments',
228
- title: `Baseline ${verticalAlign === 'bottom' ? 'center' : 'bottom'} (Press c)`,
306
+ tooltip: {
307
+ title: `Baseline ${verticalAlign === 'bottom' ? 'center' : 'bottom'}`,
308
+ shortcuts: ['c'],
309
+ description: 'To align the spectra in the centre or at the bottom of the displayer.',
310
+ },
229
311
  icon: verticalAlign === 'bottom' ? (_jsx(SvgNmrAlignCenter, {})) : (_jsx(SvgNmrAlignBottom, {})),
230
312
  condition: ftCounter > 0 || fidCounter > 0,
231
313
  onClick: alignSpectraVerticallyHandler,
232
314
  },
233
315
  ];
234
316
  return (_jsxs(_Fragment, { children: [_jsx(LoadJCAMPModal, { isOpen: dialog.loadJCAMP, onCloseDialog: closeDialog }), _jsx(ImportPublicationStringModal, { isOpen: dialog.importPublicationString, onClose: closeDialog }), _jsx(MetaImportationModal, { isOpen: dialog.metaImportation, onCloseDialog: closeDialog }), _jsx(SaveAsModal, { isOpen: dialog.saveAs, onCloseDialog: closeDialog }), _jsx(Toolbar, { vertical: true, children: toolItems.map((item) => {
235
- const { id, icon, title, checkOptions, condition } = item;
317
+ const { id, icon, tooltip, checkOptions, condition } = item;
236
318
  const show = isButtonVisible(id, checkOptions) &&
237
319
  (condition === undefined || condition);
238
320
  if (!show)
239
321
  return null;
240
322
  if (isPopoverToolItem(item)) {
241
323
  const { menuItems, onClick } = item;
242
- return (_jsx(ToolbarPopoverItem, { options: menuItems, title: title, id: id, active: selectedTool === id, icon: icon, onClick: onClick }, id));
324
+ return (_jsx(ToolbarPopoverItem, { options: menuItems, tooltip: typeof tooltip === 'string' ? (tooltip) : (_jsx(CustomToolTip, { ...tooltip })), tooltipProps: {
325
+ minimal: true,
326
+ }, id: id, active: selectedTool === id, icon: icon, onClick: onClick }, id));
243
327
  }
244
328
  const { onClick } = item;
245
- return (_jsx(Toolbar.Item, { onClick: onClick || (() => handleChange(id)), title: title, id: id, active: selectedTool === id, icon: icon }, id));
329
+ return (_jsx(Toolbar.Item, { onClick: onClick || (() => handleChange(id)), tooltip: typeof tooltip === 'string' ? (tooltip) : (_jsx(CustomToolTip, { ...tooltip })), tooltipProps: {
330
+ minimal: true,
331
+ }, id: id, active: selectedTool === id, icon: icon }, id));
246
332
  }) })] }));
247
333
  }
@@ -1,4 +1,5 @@
1
1
  import { Filters } from 'nmr-processing';
2
+ import { color2D } from '../../data/data2d/Spectrum2D/get2DColor';
2
3
  export const workspaceDefaultProperties = {
3
4
  display: {
4
5
  general: {
@@ -192,38 +193,32 @@ export const workspaceDefaultProperties = {
192
193
  {
193
194
  jpath: ['info', 'experiment'],
194
195
  value: 'cosy',
195
- positiveColor: 'darkblue',
196
- negativeColor: 'blue',
196
+ ...color2D.cosy,
197
197
  },
198
198
  {
199
199
  jpath: ['info', 'experiment'],
200
200
  value: 'noesy',
201
- positiveColor: 'pink',
202
- negativeColor: 'yellow',
201
+ ...color2D.noesy,
203
202
  },
204
203
  {
205
204
  jpath: ['info', 'experiment'],
206
205
  value: 'roesy',
207
- positiveColor: 'pink',
208
- negativeColor: 'yellow',
206
+ ...color2D.roesy,
209
207
  },
210
208
  {
211
209
  jpath: ['info', 'experiment'],
212
210
  value: 'tocsy',
213
- positiveColor: 'green',
214
- negativeColor: 'yellow',
211
+ ...color2D.tocsy,
215
212
  },
216
213
  {
217
214
  jpath: ['info', 'experiment'],
218
215
  value: 'hsqc',
219
- positiveColor: 'black',
220
- negativeColor: 'yellow',
216
+ ...color2D.hsqc,
221
217
  },
222
218
  {
223
219
  jpath: ['info', 'experiment'],
224
220
  value: 'hmbc',
225
- positiveColor: 'darkviolet',
226
- negativeColor: 'yellow',
221
+ ...color2D.hmbc,
227
222
  },
228
223
  ],
229
224
  },
@@ -1,11 +1,18 @@
1
1
  import { SpectrumOneDimensionColor } from 'nmr-load-save';
2
2
  import { UsedColors } from '../../../types/UsedColors';
3
- interface GetOnDimensionColorOption {
3
+ interface BaseColorOptions {
4
4
  usedColors?: UsedColors;
5
5
  colors?: SpectrumOneDimensionColor[];
6
- regenerate?: boolean;
7
6
  }
8
- export declare function get1DColor(spectrum: any, options: GetOnDimensionColorOption): {
7
+ interface ColorOptions extends BaseColorOptions {
8
+ regenerate?: false;
9
+ }
10
+ interface RandomColorOptions extends BaseColorOptions {
11
+ regenerate: true;
12
+ random?: boolean;
13
+ }
14
+ export declare const COLORS: Readonly<string[]>;
15
+ export declare function get1DColor(spectrum: any, options: ColorOptions | RandomColorOptions): {
9
16
  color: string;
10
17
  };
11
18
  export {};