@zakodium/nmrium-core-plugins-ui 0.1.29 → 0.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/plugins/spectrum_1d_processings_ui/operators/digital_filter.d.ts.map +1 -1
- package/lib/plugins/spectrum_1d_processings_ui/operators/digital_filter.js +2 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/digital_filter.js.map +1 -1
- package/lib/plugins/spectrum_1d_processings_ui/operators/digital_filter_panel_tool.d.ts +6 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/digital_filter_panel_tool.d.ts.map +1 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/digital_filter_panel_tool.js +32 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/digital_filter_panel_tool.js.map +1 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/fft.d.ts.map +1 -1
- package/lib/plugins/spectrum_1d_processings_ui/operators/fft.js +2 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/fft.js.map +1 -1
- package/lib/plugins/spectrum_1d_processings_ui/operators/fft_tool.d.ts +3 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/fft_tool.d.ts.map +1 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/fft_tool.js +45 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/fft_tool.js.map +1 -0
- package/package.json +4 -4
- package/src/plugins/spectrum_1d_processings_ui/operators/digital_filter.tsx +3 -0
- package/src/plugins/spectrum_1d_processings_ui/operators/digital_filter_panel_tool.tsx +62 -0
- package/src/plugins/spectrum_1d_processings_ui/operators/fft.tsx +3 -0
- package/src/plugins/spectrum_1d_processings_ui/operators/fft_tool.tsx +75 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"digital_filter.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/digital_filter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"digital_filter.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/digital_filter.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,eAAe,uGAO1B,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineProcessingOperatorUI } from '@zakodium/nmrium-core';
|
|
2
|
+
import { DigitalFilterPanelTool } from "./digital_filter_panel_tool.js";
|
|
2
3
|
const formatter = new Intl.NumberFormat('en-US');
|
|
3
4
|
export const digitalFilter1D = defineProcessingOperatorUI({
|
|
4
5
|
id: '@zakodium/nmrium-core-plugins#digitalFilter1D',
|
|
@@ -6,5 +7,6 @@ export const digitalFilter1D = defineProcessingOperatorUI({
|
|
|
6
7
|
Expanded(props) {
|
|
7
8
|
return `Value: ${formatter.format(props.operation.settings)}`;
|
|
8
9
|
},
|
|
10
|
+
PanelTool: DigitalFilterPanelTool,
|
|
9
11
|
});
|
|
10
12
|
//# sourceMappingURL=digital_filter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"digital_filter.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/digital_filter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AAEjD,MAAM,CAAC,MAAM,eAAe,GAAG,0BAA0B,CAAC;IACxD,EAAE,EAAE,+CAA+C;IACnD,IAAI,EAAE,gBAAgB;IACtB,QAAQ,CAAC,KAAK;QACZ,OAAO,UAAU,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;IAChE,CAAC;
|
|
1
|
+
{"version":3,"file":"digital_filter.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/digital_filter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAiC,CAAC;AAEzE,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AAEjD,MAAM,CAAC,MAAM,eAAe,GAAG,0BAA0B,CAAC;IACxD,EAAE,EAAE,+CAA+C;IACnD,IAAI,EAAE,gBAAgB;IACtB,QAAQ,CAAC,KAAK;QACZ,OAAO,UAAU,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;IAChE,CAAC;IACD,SAAS,EAAE,sBAAsB;CAClC,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ProcessingOperatorUIToolProps } from '@zakodium/nmrium-core';
|
|
2
|
+
declare const operatorId: "@zakodium/nmrium-core-plugins#digitalFilter1D";
|
|
3
|
+
type OperatorId = typeof operatorId;
|
|
4
|
+
export declare function DigitalFilterPanelTool(props: ProcessingOperatorUIToolProps<OperatorId>): import("react").JSX.Element | null;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=digital_filter_panel_tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digital_filter_panel_tool.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/digital_filter_panel_tool.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,6BAA6B,EAE9B,MAAM,uBAAuB,CAAC;AAM/B,QAAA,MAAM,UAAU,iDACyE,CAAC;AAC1F,KAAK,UAAU,GAAG,OAAO,UAAU,CAAC;AAepC,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,6BAA6B,CAAC,UAAU,CAAC,sCAiCjD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { generateID, isSpectrum1D } from '@zakodium/nmrium-core';
|
|
3
|
+
import { assertDefined } from '@zakodium/utils';
|
|
4
|
+
import { SvgNmrAddFilter } from 'cheminfo-font';
|
|
5
|
+
import { Toolbar, TooltipHelpContent } from 'react-science/ui';
|
|
6
|
+
const operatorId = '@zakodium/nmrium-core-plugins#digitalFilter1D';
|
|
7
|
+
function getDefaultOperation(settings) {
|
|
8
|
+
return {
|
|
9
|
+
operatorId,
|
|
10
|
+
uid: generateID(),
|
|
11
|
+
settings,
|
|
12
|
+
options: undefined,
|
|
13
|
+
enabled: true,
|
|
14
|
+
error: undefined,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function DigitalFilterPanelTool(props) {
|
|
18
|
+
const { spectrum, activeOperatorId, onTriggerOperation } = props;
|
|
19
|
+
if (!isSpectrum1D(spectrum))
|
|
20
|
+
return null;
|
|
21
|
+
const isActive = activeOperatorId === operatorId;
|
|
22
|
+
const digitalFilter = spectrum.info.digitalFilter;
|
|
23
|
+
const isDisabled = typeof digitalFilter !== 'number' || digitalFilter < 0;
|
|
24
|
+
function triggerOperation() {
|
|
25
|
+
if (isDisabled)
|
|
26
|
+
return;
|
|
27
|
+
assertDefined(digitalFilter);
|
|
28
|
+
onTriggerOperation(getDefaultOperation(digitalFilter));
|
|
29
|
+
}
|
|
30
|
+
return (_jsx(Toolbar.Item, { id: operatorId, icon: _jsx(SvgNmrAddFilter, {}), tooltip: _jsx(TooltipHelpContent, { title: "Digital filter", description: "Apply digital filter from spectrum info." }), active: isActive, disabled: isDisabled, onClick: triggerOperation }));
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=digital_filter_panel_tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digital_filter_panel_tool.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/digital_filter_panel_tool.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,a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 @@
|
|
|
1
|
-
{"version":3,"file":"fft.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/fft.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fft.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/fft.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK,6FAIhB,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { defineProcessingOperatorUI } from '@zakodium/nmrium-core';
|
|
2
|
+
import { FFTTool } from "./fft_tool.js";
|
|
2
3
|
export const fft1D = defineProcessingOperatorUI({
|
|
3
4
|
id: '@zakodium/nmrium-core-plugins#fft1D',
|
|
4
5
|
name: 'FFT',
|
|
6
|
+
Tool: FFTTool,
|
|
5
7
|
});
|
|
6
8
|
//# sourceMappingURL=fft.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fft.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/fft.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,MAAM,KAAK,GAAG,0BAA0B,CAAC;IAC9C,EAAE,EAAE,qCAAqC;IACzC,IAAI,EAAE,KAAK;
|
|
1
|
+
{"version":3,"file":"fft.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/fft.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAgB,CAAC;AAEzC,MAAM,CAAC,MAAM,KAAK,GAAG,0BAA0B,CAAC;IAC9C,EAAE,EAAE,qCAAqC;IACzC,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,OAAO;CACd,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fft_tool.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/fft_tool.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,6BAA6B,EAE9B,MAAM,uBAAuB,CAAC;AAmB/B,wBAAgB,OAAO,CACrB,KAAK,EAAE,6BAA6B,CAAC,qCAAqC,CAAC,sCAiD5E"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useHotkeys } from '@blueprintjs/core';
|
|
3
|
+
import { generateID, isSpectrum1DFid } from '@zakodium/nmrium-core';
|
|
4
|
+
import { SvgNmrFourierTransform } from 'cheminfo-font';
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
import { Toolbar, TooltipHelpContent } from 'react-science/ui';
|
|
7
|
+
import { useEventCallback } from 'usehooks-ts';
|
|
8
|
+
function defaultFFTOperation() {
|
|
9
|
+
return {
|
|
10
|
+
operatorId: '@zakodium/nmrium-core-plugins#fft1D',
|
|
11
|
+
settings: null,
|
|
12
|
+
options: undefined,
|
|
13
|
+
error: undefined,
|
|
14
|
+
uid: generateID(),
|
|
15
|
+
enabled: true,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function FFTTool(props) {
|
|
19
|
+
const { spectrum, activeOperatorId, onTriggerOperation } = props;
|
|
20
|
+
const isActive = activeOperatorId === '@zakodium/nmrium-core-plugins#fft1D';
|
|
21
|
+
const isVisible = isSpectrum1DFid(spectrum) && spectrum.info.isComplex;
|
|
22
|
+
const triggerOperation = useEventCallback((event) => {
|
|
23
|
+
if ('stopImmediatePropagation' in event) {
|
|
24
|
+
// stopPropagation is not enough because
|
|
25
|
+
// nmrium keyboard listener is also on document
|
|
26
|
+
event.stopImmediatePropagation();
|
|
27
|
+
}
|
|
28
|
+
onTriggerOperation(defaultFFTOperation());
|
|
29
|
+
});
|
|
30
|
+
const hotkeys = useMemo(() => {
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
combo: 't',
|
|
34
|
+
label: 'Fourier Transform',
|
|
35
|
+
global: true,
|
|
36
|
+
onKeyDown: triggerOperation,
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
}, [triggerOperation]);
|
|
40
|
+
useHotkeys(isVisible ? hotkeys : []);
|
|
41
|
+
if (!isVisible)
|
|
42
|
+
return null;
|
|
43
|
+
return (_jsx(Toolbar.Item, { id: "@zakodium/nmrium-core-plugins#fft1D", icon: _jsx(SvgNmrFourierTransform, {}), tooltip: _jsx(TooltipHelpContent, { title: "Fourier transform", shortcuts: ['t'], description: "Perform a Fourier transform on the FID.", link: "https://docs.nmrium.org/help/ft/" }), active: isActive, onClick: triggerOperation }));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=fft_tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fft_tool.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/fft_tool.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,SAAS,mBAAmB;IAC1B,OAAO;QACL,UAAU,EAAE,qCAAqC;QACjD,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,UAAU,EAAE;QACjB,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,OAAO,CACrB,KAA2E;IAE3E,MAAM,EAAE,QAAQ,EAAE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|
|
2
2
|
"name": "@zakodium/nmrium-core-plugins-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
4
4
|
"license": "CC-BY-NC-SA-4.0",
|
|
5
5
|
"description": "UI related plugins needed for cheminfo/nmrium",
|
|
6
6
|
"keywords": [],
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@blueprintjs/select": "^6.3.3",
|
|
29
29
|
"@emotion/styled": "^11.14.1",
|
|
30
30
|
"@tanstack/react-form": "^1.33.2",
|
|
31
|
-
"@zakodium/nmrium-core": "^0.7.
|
|
32
|
-
"@zakodium/nmrium-core-plugins": "^0.7.
|
|
31
|
+
"@zakodium/nmrium-core": "^0.7.52",
|
|
32
|
+
"@zakodium/nmrium-core-plugins": "^0.7.69",
|
|
33
33
|
"fifo-logger": "^2.0.1",
|
|
34
34
|
"react": "^18.3.1",
|
|
35
35
|
"react-dom": "^18.3.1",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"typescript": "~6.0.3",
|
|
45
45
|
"vitest": "^4.1.10"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "7aa49a1f5040e34708490477c062ec11886ebcbc"
|
|
48
48
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { defineProcessingOperatorUI } from '@zakodium/nmrium-core';
|
|
2
2
|
|
|
3
|
+
import { DigitalFilterPanelTool } from './digital_filter_panel_tool.tsx';
|
|
4
|
+
|
|
3
5
|
const formatter = new Intl.NumberFormat('en-US');
|
|
4
6
|
|
|
5
7
|
export const digitalFilter1D = defineProcessingOperatorUI({
|
|
@@ -8,4 +10,5 @@ export const digitalFilter1D = defineProcessingOperatorUI({
|
|
|
8
10
|
Expanded(props) {
|
|
9
11
|
return `Value: ${formatter.format(props.operation.settings)}`;
|
|
10
12
|
},
|
|
13
|
+
PanelTool: DigitalFilterPanelTool,
|
|
11
14
|
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ProcessingOperatorId,
|
|
3
|
+
ProcessingOperatorUIToolProps,
|
|
4
|
+
SpectrumProcessingTypeRegistry,
|
|
5
|
+
} from '@zakodium/nmrium-core';
|
|
6
|
+
import { generateID, isSpectrum1D } from '@zakodium/nmrium-core';
|
|
7
|
+
import { assertDefined } from '@zakodium/utils';
|
|
8
|
+
import { SvgNmrAddFilter } from 'cheminfo-font';
|
|
9
|
+
import { Toolbar, TooltipHelpContent } from 'react-science/ui';
|
|
10
|
+
|
|
11
|
+
const operatorId =
|
|
12
|
+
'@zakodium/nmrium-core-plugins#digitalFilter1D' as const satisfies ProcessingOperatorId;
|
|
13
|
+
type OperatorId = typeof operatorId;
|
|
14
|
+
|
|
15
|
+
function getDefaultOperation(
|
|
16
|
+
settings: number,
|
|
17
|
+
): SpectrumProcessingTypeRegistry[OperatorId] {
|
|
18
|
+
return {
|
|
19
|
+
operatorId,
|
|
20
|
+
uid: generateID(),
|
|
21
|
+
settings,
|
|
22
|
+
options: undefined,
|
|
23
|
+
enabled: true,
|
|
24
|
+
error: undefined,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function DigitalFilterPanelTool(
|
|
29
|
+
props: ProcessingOperatorUIToolProps<OperatorId>,
|
|
30
|
+
) {
|
|
31
|
+
const { spectrum, activeOperatorId, onTriggerOperation } = props;
|
|
32
|
+
|
|
33
|
+
if (!isSpectrum1D(spectrum)) return null;
|
|
34
|
+
|
|
35
|
+
const isActive = activeOperatorId === operatorId;
|
|
36
|
+
|
|
37
|
+
const digitalFilter = spectrum.info.digitalFilter;
|
|
38
|
+
const isDisabled = typeof digitalFilter !== 'number' || digitalFilter < 0;
|
|
39
|
+
|
|
40
|
+
function triggerOperation() {
|
|
41
|
+
if (isDisabled) return;
|
|
42
|
+
assertDefined(digitalFilter);
|
|
43
|
+
|
|
44
|
+
onTriggerOperation(getDefaultOperation(digitalFilter));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Toolbar.Item
|
|
49
|
+
id={operatorId}
|
|
50
|
+
icon={<SvgNmrAddFilter />}
|
|
51
|
+
tooltip={
|
|
52
|
+
<TooltipHelpContent
|
|
53
|
+
title="Digital filter"
|
|
54
|
+
description="Apply digital filter from spectrum info."
|
|
55
|
+
/>
|
|
56
|
+
}
|
|
57
|
+
active={isActive}
|
|
58
|
+
disabled={isDisabled}
|
|
59
|
+
onClick={triggerOperation}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { HotkeyConfig } from '@blueprintjs/core';
|
|
2
|
+
import { useHotkeys } from '@blueprintjs/core';
|
|
3
|
+
import type {
|
|
4
|
+
ProcessingOperatorUIToolProps,
|
|
5
|
+
Spectrum1DProcessingTypeRegistry,
|
|
6
|
+
} from '@zakodium/nmrium-core';
|
|
7
|
+
import { generateID, isSpectrum1DFid } from '@zakodium/nmrium-core';
|
|
8
|
+
import { SvgNmrFourierTransform } from 'cheminfo-font';
|
|
9
|
+
import type { MouseEvent } from 'react';
|
|
10
|
+
import { useMemo } from 'react';
|
|
11
|
+
import { Toolbar, TooltipHelpContent } from 'react-science/ui';
|
|
12
|
+
import { useEventCallback } from 'usehooks-ts';
|
|
13
|
+
|
|
14
|
+
function defaultFFTOperation(): Spectrum1DProcessingTypeRegistry['@zakodium/nmrium-core-plugins#fft1D'] {
|
|
15
|
+
return {
|
|
16
|
+
operatorId: '@zakodium/nmrium-core-plugins#fft1D',
|
|
17
|
+
settings: null,
|
|
18
|
+
options: undefined,
|
|
19
|
+
error: undefined,
|
|
20
|
+
uid: generateID(),
|
|
21
|
+
enabled: true,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function FFTTool(
|
|
26
|
+
props: ProcessingOperatorUIToolProps<'@zakodium/nmrium-core-plugins#fft1D'>,
|
|
27
|
+
) {
|
|
28
|
+
const { spectrum, activeOperatorId, onTriggerOperation } = props;
|
|
29
|
+
|
|
30
|
+
const isActive = activeOperatorId === '@zakodium/nmrium-core-plugins#fft1D';
|
|
31
|
+
const isVisible = isSpectrum1DFid(spectrum) && spectrum.info.isComplex;
|
|
32
|
+
|
|
33
|
+
const triggerOperation = useEventCallback(
|
|
34
|
+
(event: KeyboardEvent | MouseEvent) => {
|
|
35
|
+
if ('stopImmediatePropagation' in event) {
|
|
36
|
+
// stopPropagation is not enough because
|
|
37
|
+
// nmrium keyboard listener is also on document
|
|
38
|
+
event.stopImmediatePropagation();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
onTriggerOperation(defaultFFTOperation());
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const hotkeys = useMemo<HotkeyConfig[]>(() => {
|
|
46
|
+
return [
|
|
47
|
+
{
|
|
48
|
+
combo: 't',
|
|
49
|
+
label: 'Fourier Transform',
|
|
50
|
+
global: true,
|
|
51
|
+
onKeyDown: triggerOperation,
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
}, [triggerOperation]);
|
|
55
|
+
|
|
56
|
+
useHotkeys(isVisible ? hotkeys : []);
|
|
57
|
+
if (!isVisible) return null;
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Toolbar.Item
|
|
61
|
+
id="@zakodium/nmrium-core-plugins#fft1D"
|
|
62
|
+
icon={<SvgNmrFourierTransform />}
|
|
63
|
+
tooltip={
|
|
64
|
+
<TooltipHelpContent
|
|
65
|
+
title="Fourier transform"
|
|
66
|
+
shortcuts={['t']}
|
|
67
|
+
description="Perform a Fourier transform on the FID."
|
|
68
|
+
link="https://docs.nmrium.org/help/ft/"
|
|
69
|
+
/>
|
|
70
|
+
}
|
|
71
|
+
active={isActive}
|
|
72
|
+
onClick={triggerOperation}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
}
|