nmrium 0.50.1 → 0.51.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.
- package/lib/component/1d/Chart1D.js +1 -1
- package/lib/component/1d/LinesSeries.js +2 -2
- package/lib/component/1d/Viewer1D.js +6 -11
- package/lib/component/1d/database/DatabaseSpectrum.js +3 -3
- package/lib/component/2d/1d-tracer/HorizontalSliceChart.js +6 -2
- package/lib/component/2d/1d-tracer/VerticalSliceChart.js +8 -1
- package/lib/component/2d/1d-tracer/phase-correction-traces/PhaseTraceWithMouse.js +2 -21
- package/lib/component/2d/1d-tracer/phase-correction-traces/PhaseTraces.js +1 -1
- package/lib/component/2d/1d-tracer/phase-correction-traces/SpectraPhaseTraces.d.ts +1 -1
- package/lib/component/2d/1d-tracer/phase-correction-traces/SpectraPhaseTraces.js +6 -17
- package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.d.ts +6 -10
- package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.js +62 -13
- package/lib/component/2d/1d-tracer/phase-correction-traces/useActivePhaseTraces.d.ts +1 -0
- package/lib/component/2d/1d-tracer/phase-correction-traces/useActivePhaseTraces.js +2 -1
- package/lib/component/2d/Viewer2D.js +16 -15
- package/lib/component/2d/ft/Contours.js +6 -3
- package/lib/component/2d/utilities/scale.d.ts +2 -1
- package/lib/component/2d/utilities/scale.js +12 -2
- package/lib/component/EventsTrackers/BrushTracker.d.ts +5 -3
- package/lib/component/EventsTrackers/BrushTracker.js +2 -2
- package/lib/component/EventsTrackers/KeysListenerTracker.d.ts +1 -1
- package/lib/component/EventsTrackers/KeysListenerTracker.js +29 -15
- package/lib/component/context/ToasterContext.d.ts +13 -0
- package/lib/component/context/ToasterContext.js +34 -0
- package/lib/component/elements/Select.js +2 -2
- package/lib/component/elements/ToolbarPopoverItem.js +1 -1
- package/lib/component/header/AutoPeakPickingOptionPanel.js +6 -3
- package/lib/component/header/Header.d.ts +1 -11
- package/lib/component/header/Header.js +5 -6
- package/lib/component/header/PhaseCorrectionPanel.js +24 -33
- package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.d.ts +1 -1
- package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.js +96 -42
- package/lib/component/header/RangesPickingOptionPanel.js +6 -3
- package/lib/component/hooks/useDialogToggle.d.ts +5 -0
- package/lib/component/hooks/useDialogToggle.js +16 -0
- package/lib/component/hooks/useExport.d.ts +9 -1
- package/lib/component/hooks/useExport.js +34 -36
- package/lib/component/hooks/useSaveSettings.js +6 -3
- package/lib/component/hooks/useToolsFunctions.js +6 -4
- package/lib/component/loader/DropZone.js +14 -14
- package/lib/component/main/InnerNMRium.js +5 -9
- package/lib/component/main/InnerNMRiumContents.d.ts +0 -2
- package/lib/component/main/InnerNMRiumContents.js +5 -3
- package/lib/component/main/NMRium.js +2 -2
- package/lib/component/modal/AboutPredictionModal.js +1 -1
- package/lib/component/modal/ExportAsJcampModal.js +15 -15
- package/lib/component/modal/ImportPublicationStringModal.js +5 -3
- package/lib/component/modal/LoadJCAMPModal.js +6 -4
- package/lib/component/modal/PredictSpectraModal.js +11 -9
- package/lib/component/modal/SaveAsModal.d.ts +3 -4
- package/lib/component/modal/SaveAsModal.js +27 -27
- package/lib/component/modal/editRange/EditRangeModal.js +2 -2
- package/lib/component/modal/editRange/forms/components/DeltaInput.d.ts +2 -3
- package/lib/component/modal/editRange/forms/components/DeltaInput.js +2 -3
- package/lib/component/modal/editRange/forms/components/InfoBlock.d.ts +1 -0
- package/lib/component/modal/editRange/forms/components/{SignalFormInfo.js → InfoBlock.js} +2 -2
- package/lib/component/modal/editRange/forms/components/NewSignalTab.d.ts +5 -0
- package/lib/component/modal/editRange/forms/components/NewSignalTab.js +85 -0
- package/lib/component/modal/editRange/forms/components/SignalTab.d.ts +7 -0
- package/lib/component/modal/editRange/forms/components/SignalTab.js +24 -0
- package/lib/component/modal/editRange/forms/components/SignalsContent.d.ts +8 -0
- package/lib/component/modal/editRange/forms/components/SignalsContent.js +57 -0
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.d.ts +5 -0
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +133 -0
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.d.ts +5 -0
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +141 -0
- package/lib/component/modal/metaImportation/MetaImportationModal.d.ts +7 -4
- package/lib/component/modal/metaImportation/MetaImportationModal.js +23 -13
- package/lib/component/modal/metaImportation/utils/mapColumnToSelectItems.js +1 -1
- package/lib/component/modal/setting/GeneralSettings.js +7 -4
- package/lib/component/panels/AutomaticAssignment/useAutoAssignments.js +7 -4
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +13 -7
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +6 -4
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +6 -3
- package/lib/component/panels/RangesPanel/RangesHeader.js +3 -3
- package/lib/component/panels/RangesPanel/RangesPanel.js +4 -4
- package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -3
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +11 -5
- package/lib/component/panels/databasePanel/DatabasePanel.js +37 -19
- package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +1 -1
- package/lib/component/panels/filtersPanel/FilterPanel.js +5 -3
- package/lib/component/panels/filtersPanel/FiltersTable.js +27 -23
- package/lib/component/panels/header/SpectraAutomaticPickingButton.js +6 -4
- package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +2 -2
- package/lib/component/panels/multipleAnalysisPanel/AnalysisChart.js +3 -3
- package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +5 -5
- package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +4 -2
- package/lib/component/panels/predictionPanel/PredictionPanel.js +7 -5
- package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +1 -0
- package/lib/component/reducer/Reducer.d.ts +2 -2
- package/lib/component/reducer/Reducer.js +23 -16
- package/lib/component/reducer/actions/FiltersActions.d.ts +11 -4
- package/lib/component/reducer/actions/FiltersActions.js +243 -91
- package/lib/component/reducer/actions/IntegralsActions.js +2 -2
- package/lib/component/reducer/actions/MoleculeActions.js +0 -1
- package/lib/component/reducer/actions/RangesActions.js +16 -6
- package/lib/component/reducer/actions/ToolsActions.d.ts +3 -3
- package/lib/component/reducer/actions/ToolsActions.js +75 -14
- package/lib/component/reducer/helper/Zoom1DManager.d.ts +4 -3
- package/lib/component/reducer/helper/Zoom1DManager.js +4 -4
- package/lib/component/reducer/helper/ZoomHistoryManager.js +1 -5
- package/lib/component/reducer/helper/findStrongestPeak.d.ts +6 -0
- package/lib/component/reducer/helper/findStrongestPeak.js +13 -0
- package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.d.ts +2 -1
- package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.js +7 -1
- package/lib/component/toolbar/ToolBar.js +17 -12
- package/lib/component/utility/Events.d.ts +11 -0
- package/lib/component/utility/Events.js +22 -0
- package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +0 -33
- package/lib/data/data1d/Spectrum1D/ranges/addRange.js +5 -15
- package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -4
- package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectRanges.d.ts +6 -4
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +13 -3
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +6 -0
- package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.d.ts +13 -3
- package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js +78 -18
- package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +2 -2
- package/lib/data/data1d/spectrumSimulation.d.ts +1 -1
- package/lib/data/data2d/Spectrum2D/contours.js +3 -3
- package/lib/data/data2d/Spectrum2D/getMissingProjection.js +2 -2
- package/lib/data/data2d/Spectrum2D/getSlice.js +3 -3
- package/lib/data/getDefaultMatrixFilters.js +2 -2
- package/lib/data/matrixGeneration.js +1 -1
- package/lib/data/utilities/calculateSanPlot.d.ts +1 -6
- package/lib/versionInfo.js +1 -1
- package/package.json +31 -30
- package/lib/component/elements/popup/Alert/AlertBlock.d.ts +0 -8
- package/lib/component/elements/popup/Alert/AlertBlock.js +0 -30
- package/lib/component/elements/popup/Alert/Context.d.ts +0 -27
- package/lib/component/elements/popup/Alert/Context.js +0 -10
- package/lib/component/elements/popup/Alert/ProgressIndicator.d.ts +0 -1
- package/lib/component/elements/popup/Alert/ProgressIndicator.js +0 -33
- package/lib/component/elements/popup/Alert/Provider.d.ts +0 -19
- package/lib/component/elements/popup/Alert/Provider.js +0 -127
- package/lib/component/elements/popup/Alert/index.d.ts +0 -3
- package/lib/component/elements/popup/Alert/index.js +0 -3
- package/lib/component/modal/editRange/forms/components/AddSignalFormTab.d.ts +0 -10
- package/lib/component/modal/editRange/forms/components/AddSignalFormTab.js +0 -81
- package/lib/component/modal/editRange/forms/components/CouplingsTable.d.ts +0 -13
- package/lib/component/modal/editRange/forms/components/CouplingsTable.js +0 -63
- package/lib/component/modal/editRange/forms/components/SignalFormInfo.d.ts +0 -1
- package/lib/component/modal/editRange/forms/components/SignalFormTab.d.ts +0 -8
- package/lib/component/modal/editRange/forms/components/SignalFormTab.js +0 -18
- package/lib/component/modal/editRange/forms/components/SignalsForm.d.ts +0 -10
- package/lib/component/modal/editRange/forms/components/SignalsForm.js +0 -114
- package/lib/component/modal/metaImportation/index.d.ts +0 -2
- package/lib/component/modal/metaImportation/index.js +0 -17
- package/lib/component/reducer/helper/getStrongestPeak.d.ts +0 -7
- package/lib/component/reducer/helper/getStrongestPeak.js +0 -15
|
@@ -1,27 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
3
|
+
import { useOnOff } from 'react-science/ui';
|
|
2
4
|
import checkModifierKeyActivated from '../../data/utilities/checkModifierKeyActivated';
|
|
3
5
|
import { useAssignmentData } from '../assignment/AssignmentsContext';
|
|
4
6
|
import { useChartData } from '../context/ChartContext';
|
|
5
7
|
import { useDispatch } from '../context/DispatchContext';
|
|
6
8
|
import { useLoader } from '../context/LoaderContext';
|
|
7
9
|
import { usePreferences } from '../context/PreferencesContext';
|
|
8
|
-
import {
|
|
10
|
+
import { useToaster } from '../context/ToasterContext';
|
|
9
11
|
import { useModal } from '../elements/popup/Modal';
|
|
10
12
|
import { HighlightEventSource, useHighlightData } from '../highlight/index';
|
|
11
13
|
import { useCheckToolsVisibility } from '../hooks/useCheckToolsVisibility';
|
|
12
14
|
import useExport from '../hooks/useExport';
|
|
13
15
|
import useToolsFunctions from '../hooks/useToolsFunctions';
|
|
16
|
+
import SaveAsModal from '../modal/SaveAsModal';
|
|
14
17
|
import { options } from '../toolbar/ToolTypes';
|
|
15
18
|
function KeysListenerTracker(props) {
|
|
16
19
|
const { mainDivRef } = props;
|
|
17
20
|
const { keysPreferences, displayerMode, data, view: { spectra: { activeTab }, }, } = useChartData();
|
|
18
21
|
const dispatch = useDispatch();
|
|
19
22
|
const { dispatch: dispatchPreferences } = usePreferences();
|
|
20
|
-
const
|
|
23
|
+
const toaster = useToaster();
|
|
21
24
|
const modal = useModal();
|
|
22
25
|
const openLoader = useLoader();
|
|
26
|
+
const [isSaveModalOpened, openSaveAsDialog, closeSaveAsDialog] = useOnOff(false);
|
|
23
27
|
const { handleChangeOption, handleFullZoomOut, alignSpectrumsVerticallyHandler, changeDisplayViewModeHandler, } = useToolsFunctions();
|
|
24
|
-
const { saveToClipboardHandler, saveAsJSONHandler
|
|
28
|
+
const { saveToClipboardHandler, saveAsJSONHandler } = useExport();
|
|
25
29
|
const isToolVisible = useCheckToolsVisibility();
|
|
26
30
|
const { highlight, remove } = useHighlightData();
|
|
27
31
|
const mouseIsOverDisplayer = useRef(false);
|
|
@@ -129,7 +133,9 @@ function KeysListenerTracker(props) {
|
|
|
129
133
|
text: 'Yes, for all spectra',
|
|
130
134
|
handler: async () => {
|
|
131
135
|
if (zone) {
|
|
132
|
-
const hideLoading =
|
|
136
|
+
const hideLoading = toaster.showLoading({
|
|
137
|
+
message: 'Delete all spectra exclusion zones in progress',
|
|
138
|
+
});
|
|
133
139
|
dispatch({
|
|
134
140
|
type: 'DELETE_EXCLUSION_ZONE',
|
|
135
141
|
payload: {
|
|
@@ -144,7 +150,9 @@ function KeysListenerTracker(props) {
|
|
|
144
150
|
text: 'Yes',
|
|
145
151
|
handler: async () => {
|
|
146
152
|
if (spectrumID) {
|
|
147
|
-
const hideLoading =
|
|
153
|
+
const hideLoading = toaster.showLoading({
|
|
154
|
+
message: 'Delete exclusion zones in progress',
|
|
155
|
+
});
|
|
148
156
|
dispatch({
|
|
149
157
|
type: 'DELETE_EXCLUSION_ZONE',
|
|
150
158
|
payload: {
|
|
@@ -171,7 +179,9 @@ function KeysListenerTracker(props) {
|
|
|
171
179
|
text: 'Yes',
|
|
172
180
|
handler: async () => {
|
|
173
181
|
if (zone) {
|
|
174
|
-
const hideLoading =
|
|
182
|
+
const hideLoading = toaster.showLoading({
|
|
183
|
+
message: 'Delete all spectra exclusion zones in progress',
|
|
184
|
+
});
|
|
175
185
|
dispatchPreferences({
|
|
176
186
|
type: 'DELETE_MATRIX_GENERATION_EXCLUSION_ZONE',
|
|
177
187
|
payload: {
|
|
@@ -232,7 +242,7 @@ function KeysListenerTracker(props) {
|
|
|
232
242
|
remove,
|
|
233
243
|
assignmentData,
|
|
234
244
|
modal,
|
|
235
|
-
|
|
245
|
+
toaster,
|
|
236
246
|
dispatchPreferences,
|
|
237
247
|
activeTab,
|
|
238
248
|
]);
|
|
@@ -245,7 +255,9 @@ function KeysListenerTracker(props) {
|
|
|
245
255
|
keyCode: num,
|
|
246
256
|
},
|
|
247
257
|
});
|
|
248
|
-
|
|
258
|
+
toaster.show({
|
|
259
|
+
message: `Configuration Reset, press '${num}' again to reload it.`,
|
|
260
|
+
});
|
|
249
261
|
}
|
|
250
262
|
else if (!checkModifierKeyActivated(e)) {
|
|
251
263
|
if (keysPreferences?.[num]) {
|
|
@@ -263,11 +275,13 @@ function KeysListenerTracker(props) {
|
|
|
263
275
|
keyCode: num,
|
|
264
276
|
},
|
|
265
277
|
});
|
|
266
|
-
|
|
278
|
+
toaster.show({
|
|
279
|
+
message: `Configuration saved, press '${num}' again to reload it.`,
|
|
280
|
+
});
|
|
267
281
|
}
|
|
268
282
|
}
|
|
269
283
|
}
|
|
270
|
-
}, [
|
|
284
|
+
}, [data, dispatch, keysPreferences, toaster]);
|
|
271
285
|
const toolsListenerHandler = useCallback((e) => {
|
|
272
286
|
try {
|
|
273
287
|
if (!e.shiftKey && !e.metaKey && !e.ctrlKey) {
|
|
@@ -384,7 +398,7 @@ function KeysListenerTracker(props) {
|
|
|
384
398
|
switch (e.key) {
|
|
385
399
|
case 's':
|
|
386
400
|
case 'S':
|
|
387
|
-
|
|
401
|
+
openSaveAsDialog();
|
|
388
402
|
e.preventDefault();
|
|
389
403
|
break;
|
|
390
404
|
default:
|
|
@@ -393,10 +407,9 @@ function KeysListenerTracker(props) {
|
|
|
393
407
|
}
|
|
394
408
|
catch (error) {
|
|
395
409
|
reportError(error);
|
|
396
|
-
|
|
410
|
+
toaster.show({ message: error.message, intent: 'danger' });
|
|
397
411
|
}
|
|
398
412
|
}, [
|
|
399
|
-
alert,
|
|
400
413
|
alignSpectrumsVerticallyHandler,
|
|
401
414
|
allow1DTool,
|
|
402
415
|
changeDisplayViewModeHandler,
|
|
@@ -405,9 +418,10 @@ function KeysListenerTracker(props) {
|
|
|
405
418
|
handleFullZoomOut,
|
|
406
419
|
isToolVisible,
|
|
407
420
|
openLoader,
|
|
408
|
-
|
|
421
|
+
openSaveAsDialog,
|
|
409
422
|
saveAsJSONHandler,
|
|
410
423
|
saveToClipboardHandler,
|
|
424
|
+
toaster,
|
|
411
425
|
]);
|
|
412
426
|
const handleOnKeyDown = useCallback((e) => {
|
|
413
427
|
if (checkNotInputField(e) && mouseIsOverDisplayer.current) {
|
|
@@ -434,7 +448,7 @@ function KeysListenerTracker(props) {
|
|
|
434
448
|
document.addEventListener('keydown', handleOnKeyDown);
|
|
435
449
|
return () => document.removeEventListener('keydown', handleOnKeyDown);
|
|
436
450
|
}, [handleOnKeyDown]);
|
|
437
|
-
return
|
|
451
|
+
return (_jsx(SaveAsModal, { isOpen: isSaveModalOpened, onCloseDialog: closeSaveAsDialog }));
|
|
438
452
|
}
|
|
439
453
|
function checkNotInputField(e) {
|
|
440
454
|
const tags = ['input', 'textarea'];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OverlayToaster, ToastProps } from '@blueprintjs/core';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
interface ToasterContextProps {
|
|
4
|
+
toaster: OverlayToaster | null;
|
|
5
|
+
showLoading: (options: ToastProps) => () => void;
|
|
6
|
+
show: (options: ToastProps) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function useToaster(): ToasterContextProps;
|
|
9
|
+
interface ToasterProviderProps {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare function ToasterProvider({ children }: ToasterProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Classes, OverlayToaster, Position, Spinner, } from '@blueprintjs/core';
|
|
3
|
+
import { createContext, useContext, useMemo, useRef } from 'react';
|
|
4
|
+
const ToasterContext = createContext(null);
|
|
5
|
+
export function useToaster() {
|
|
6
|
+
const context = useContext(ToasterContext);
|
|
7
|
+
if (!context) {
|
|
8
|
+
throw new Error('Toaster context was not found');
|
|
9
|
+
}
|
|
10
|
+
return context;
|
|
11
|
+
}
|
|
12
|
+
export function ToasterProvider({ children }) {
|
|
13
|
+
const toasterRef = useRef(null);
|
|
14
|
+
const toaster = useMemo(() => {
|
|
15
|
+
function show(options) {
|
|
16
|
+
toasterRef.current?.show(options);
|
|
17
|
+
}
|
|
18
|
+
function showLoading(options) {
|
|
19
|
+
const { message, ...otherProps } = options;
|
|
20
|
+
const toastKey = toasterRef.current?.show({
|
|
21
|
+
message: (_jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsx(Spinner, { size: 25 }), _jsx("span", { style: { marginLeft: '0.5em' }, children: message })] })),
|
|
22
|
+
timeout: 0,
|
|
23
|
+
...otherProps,
|
|
24
|
+
});
|
|
25
|
+
return () => {
|
|
26
|
+
if (toastKey) {
|
|
27
|
+
toasterRef.current?.dismiss(toastKey);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return { toaster: toasterRef.current, showLoading, show };
|
|
32
|
+
}, []);
|
|
33
|
+
return (_jsxs(_Fragment, { children: [_jsx(OverlayToaster, { className: Classes.DARK, position: Position.BOTTOM, ref: toasterRef }), _jsx(ToasterContext.Provider, { value: toaster, children: children })] }));
|
|
34
|
+
}
|
|
@@ -32,13 +32,13 @@ const styles = {
|
|
|
32
32
|
},
|
|
33
33
|
};
|
|
34
34
|
const Select = forwardRef(function Select(props, ref) {
|
|
35
|
-
const { items, style = { width: 100 }, onChange = () => null, defaultValue, value, name = '', className = '', placeholder = '', itemValueField = 'value', itemTextField = 'label', returnValue = true, textRender, } = props;
|
|
35
|
+
const { items, style = { width: 100 }, onChange = () => null, defaultValue, value, name = '', className = '', placeholder = '', itemValueField = 'value', itemTextField = 'label', returnValue = true, textRender, ...otherProps } = props;
|
|
36
36
|
const handleOnChanged = useCallback((e) => {
|
|
37
37
|
const [option] = e.target.selectedOptions;
|
|
38
38
|
const selectedData = JSON.parse(option.dataset.value);
|
|
39
39
|
onChange(returnValue ? selectedData[itemValueField] : selectedData);
|
|
40
40
|
}, [itemValueField, onChange, returnValue]);
|
|
41
|
-
return (_jsxs("select", { ref: ref, css: styles.select(style?.width), name: name, onChange: handleOnChanged, defaultValue: defaultValue, value: value, className: className, style: style, required: true, children: [placeholder && (_jsx("option", { value: "", disabled: true, children: placeholder })), items.map((option) => {
|
|
41
|
+
return (_jsxs("select", { ref: ref, css: styles.select(style?.width), name: name, onChange: handleOnChanged, defaultValue: defaultValue, value: value, className: className, style: style, required: true, ...otherProps, children: [placeholder && (_jsx("option", { value: "", disabled: true, children: placeholder })), items.map((option) => {
|
|
42
42
|
const value = option[itemValueField];
|
|
43
43
|
if (!['number', 'string'].includes(typeof option[itemTextField])) {
|
|
44
44
|
// eslint-disable-next-line no-console
|
|
@@ -5,6 +5,6 @@ export function ToolbarPopoverItem(props) {
|
|
|
5
5
|
const { options, onClick, ...itemProps } = props;
|
|
6
6
|
return (_jsx(Toolbar.PopoverItem, { content: _jsx(Menu, { children: options.map((option) => {
|
|
7
7
|
const { data, ...otherOptions } = option;
|
|
8
|
-
return (_jsx(MenuItem, { ...otherOptions, onClick: () => onClick(data) }, JSON.stringify(
|
|
8
|
+
return (_jsx(MenuItem, { ...otherOptions, onClick: () => onClick(data) }, JSON.stringify(option)));
|
|
9
9
|
}) }), itemProps: itemProps }));
|
|
10
10
|
}
|
|
@@ -3,11 +3,11 @@ import { Formik } from 'formik';
|
|
|
3
3
|
import { memo } from 'react';
|
|
4
4
|
import * as Yup from 'yup';
|
|
5
5
|
import { useDispatch } from '../context/DispatchContext';
|
|
6
|
+
import { useToaster } from '../context/ToasterContext';
|
|
6
7
|
import Button from '../elements/Button';
|
|
7
8
|
import Label from '../elements/Label';
|
|
8
9
|
import FormikInput from '../elements/formik/FormikInput';
|
|
9
10
|
import FormikSelect from '../elements/formik/FormikSelect';
|
|
10
|
-
import { useAlert } from '../elements/popup/Alert';
|
|
11
11
|
import { MIN_AREA_POINTS, useCheckPointsNumberInWindowArea, } from '../hooks/useCheckPointsNumberInWindowArea';
|
|
12
12
|
import { headerLabelStyle } from './Header';
|
|
13
13
|
import { HeaderContainer } from './HeaderContainer';
|
|
@@ -46,7 +46,7 @@ const INIT_VALUES = {
|
|
|
46
46
|
function AutoPeakPickingOptionPanel() {
|
|
47
47
|
const dispatch = useDispatch();
|
|
48
48
|
const pointsNumber = useCheckPointsNumberInWindowArea();
|
|
49
|
-
const
|
|
49
|
+
const toaster = useToaster();
|
|
50
50
|
function handlePeakPicking(values) {
|
|
51
51
|
if (pointsNumber > MIN_AREA_POINTS) {
|
|
52
52
|
dispatch({
|
|
@@ -55,7 +55,10 @@ function AutoPeakPickingOptionPanel() {
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
|
-
|
|
58
|
+
toaster.show({
|
|
59
|
+
message: `Auto peak picking only available for area more than ${MIN_AREA_POINTS} points`,
|
|
60
|
+
intent: 'danger',
|
|
61
|
+
});
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
64
|
return (_jsx(HeaderContainer, { children: _jsx(Formik, { initialValues: INIT_VALUES, onSubmit: handlePeakPicking, validationSchema: validationSchema, children: ({ handleSubmit, isValid }) => (_jsxs(_Fragment, { children: [_jsx(Label, { title: "Direction : ", shortTitle: "", style: headerLabelStyle, children: _jsx(FormikSelect, { name: "direction", items: LookFor, style: { width: '85px' } }) }), _jsx(Label, { title: "Max Number Of Peaks :", shortTitle: "Peaks number :", style: headerLabelStyle, children: _jsx(FormikInput, { type: "number", name: "maxNumberOfPeaks", style: inputStyle, min: 0, step: 1 }) }), _jsx(Label, { title: "Noise factor :", shortTitle: "Noise :", style: headerLabelStyle, children: _jsx(FormikInput, { type: "number", name: "noiseFactor", style: inputStyle, min: 0 }) }), _jsx(Label, { title: "Min Max Ratio :", shortTitle: "Ratio :", style: headerLabelStyle, children: _jsx(FormikInput, { type: "number", name: "minMaxRatio", style: inputStyle, step: 0.01, min: 0 }) }), _jsx(Button.Done, { onClick: () => handleSubmit(), style: { margin: '0 10px' }, disabled: !isValid, children: "Apply" })] })) }) }));
|
|
@@ -1,13 +1,3 @@
|
|
|
1
1
|
import { LabelStyle } from '../elements/Label';
|
|
2
2
|
export declare const headerLabelStyle: LabelStyle;
|
|
3
|
-
|
|
4
|
-
onEnableFullscreen: () => void;
|
|
5
|
-
isFullscreenEnabled: boolean;
|
|
6
|
-
selectedOptionPanel: string | null;
|
|
7
|
-
height: number;
|
|
8
|
-
}
|
|
9
|
-
export default function HeaderWrapper({ isFullscreenEnabled, onEnableFullscreen, }: {
|
|
10
|
-
isFullscreenEnabled: HeaderInnerProps['isFullscreenEnabled'];
|
|
11
|
-
onEnableFullscreen: HeaderInnerProps['onEnableFullscreen'];
|
|
12
|
-
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
13
|
-
export {};
|
|
3
|
+
export default function HeaderWrapper(): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/reac
|
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { useMemo, useCallback, memo } from 'react';
|
|
5
5
|
import { FaRegWindowMaximize, FaQuestionCircle, FaRegSave, FaFilm, } from 'react-icons/fa';
|
|
6
|
-
import { Toolbar } from 'react-science/ui';
|
|
6
|
+
import { Toolbar, useFullscreen } from 'react-science/ui';
|
|
7
7
|
import { docsBaseUrl } from '../../constants';
|
|
8
8
|
import { useChartData } from '../context/ChartContext';
|
|
9
9
|
import { usePreferences, useWorkspacesList, } from '../context/PreferencesContext';
|
|
@@ -62,8 +62,9 @@ const styles = css `
|
|
|
62
62
|
}
|
|
63
63
|
`;
|
|
64
64
|
function HeaderInner(props) {
|
|
65
|
-
const {
|
|
65
|
+
const { selectedOptionPanel, height } = props;
|
|
66
66
|
const { current: { display: { general }, }, workspace, dispatch, } = usePreferences();
|
|
67
|
+
const fullscreen = useFullscreen();
|
|
67
68
|
const workspacesList = useWorkspacesList();
|
|
68
69
|
const hideGeneralSettings = !!(general?.hideGeneralSettings && workspace.base);
|
|
69
70
|
const hideWorkspaces = !!(general?.hideWorkspaces && workspace.base);
|
|
@@ -104,7 +105,7 @@ function HeaderInner(props) {
|
|
|
104
105
|
alignItems: 'center',
|
|
105
106
|
}, children: [_jsx("div", { children: _jsx(Toolbar, { children: _jsx(AboutUsModal, {}) }) }), _jsx("div", { className: "toolOptionsPanel", style: { flex: 1 }, children: selectedPanel })] }), _jsxs(HeaderContainer, { style: {
|
|
106
107
|
alignItems: 'center',
|
|
107
|
-
}, children: [!hideWorkspaces && (_jsx(DropDownButton, { data: workspacesList, selectedKey: workspace.current, onSelect: changeWorkspaceHandler, renderItem: renderItem })), !hideGeneralSettings && _jsx(SaveButton, {}), !general?.hideLogs && _jsx(LogsHistoryModal, {}), _jsx("div", { children: _jsxs(Toolbar, { children: [!general?.hideHelp && (_jsx(Toolbar.Item, { id: "user-manual", title: "User manual", onClick: () => window.open(docsBaseUrl, '_blank'), icon: _jsx(FaQuestionCircle, {}) })), _jsx(Toolbar.Item, { id: "user-manual", title: "NMRium channel", onClick: () => window.open('https://www.youtube.com/@nmrium', '_blank'), icon: _jsx(FaFilm, {}) }), !hideGeneralSettings && (_jsx(GeneralSettingsModal, { height: height / 2 })), !
|
|
108
|
+
}, children: [!hideWorkspaces && (_jsx(DropDownButton, { data: workspacesList, selectedKey: workspace.current, onSelect: changeWorkspaceHandler, renderItem: renderItem })), !hideGeneralSettings && _jsx(SaveButton, {}), !general?.hideLogs && _jsx(LogsHistoryModal, {}), _jsx("div", { children: _jsxs(Toolbar, { children: [!general?.hideHelp && (_jsx(Toolbar.Item, { id: "user-manual", title: "User manual", onClick: () => window.open(docsBaseUrl, '_blank'), icon: _jsx(FaQuestionCircle, {}) })), _jsx(Toolbar.Item, { id: "user-manual", title: "NMRium channel", onClick: () => window.open('https://www.youtube.com/@nmrium', '_blank'), icon: _jsx(FaFilm, {}) }), !hideGeneralSettings && (_jsx(GeneralSettingsModal, { height: height / 2 })), !fullscreen.isFullScreen && !general?.hideMaximize && (_jsx(Toolbar.Item, { id: "full-screen", onClick: fullscreen.toggle, title: "Full Screen", className: "windowButton", icon: _jsx(FaRegWindowMaximize, {}) }))] }) })] })] }) }));
|
|
108
109
|
}
|
|
109
110
|
function SaveButton() {
|
|
110
111
|
const { workspace, workspaces, originalWorkspaces } = usePreferences();
|
|
@@ -121,10 +122,8 @@ function SaveButton() {
|
|
|
121
122
|
}), toolTip: "Save workspace locally in the browser", children: _jsx(FaRegSave, {}) }), _jsx(SaveSettingsModal, {})] }));
|
|
122
123
|
}
|
|
123
124
|
const MemoizedHeader = memo(HeaderInner);
|
|
124
|
-
export default function HeaderWrapper(
|
|
125
|
+
export default function HeaderWrapper() {
|
|
125
126
|
const { toolOptions: { selectedOptionPanel }, height, } = useChartData();
|
|
126
127
|
return (_jsx(MemoizedHeader, { selectedOptionPanel,
|
|
127
|
-
isFullscreenEnabled,
|
|
128
|
-
onEnableFullscreen,
|
|
129
128
|
height }));
|
|
130
129
|
}
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Select } from '@blueprintjs/select';
|
|
2
3
|
import { Filters } from 'nmr-processing';
|
|
3
4
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { Button, useSelect } from 'react-science/ui';
|
|
4
6
|
import { useChartData } from '../context/ChartContext';
|
|
5
7
|
import { useDispatch } from '../context/DispatchContext';
|
|
6
8
|
import ActionButtons from '../elements/ActionButtons';
|
|
7
9
|
import Input from '../elements/Input';
|
|
8
10
|
import InputRange from '../elements/InputRange';
|
|
9
11
|
import Label from '../elements/Label';
|
|
10
|
-
import Select from '../elements/Select';
|
|
11
12
|
import { useFilter } from '../hooks/useFilter';
|
|
12
13
|
import useSpectrum from '../hooks/useSpectrum';
|
|
13
14
|
import { headerLabelStyle } from './Header';
|
|
14
15
|
import { HeaderContainer } from './HeaderContainer';
|
|
15
|
-
const selectStyle = {
|
|
16
|
-
marginLeft: '5px',
|
|
17
|
-
marginRight: '10px',
|
|
18
|
-
border: 'none',
|
|
19
|
-
height: '20px',
|
|
20
|
-
};
|
|
21
16
|
const inputStyle = {
|
|
22
17
|
input: {
|
|
23
18
|
width: '70px',
|
|
@@ -27,23 +22,19 @@ const inputStyle = {
|
|
|
27
22
|
height: '100%',
|
|
28
23
|
},
|
|
29
24
|
};
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
absolute: 'absolute',
|
|
25
|
+
const defaultPhasingTypeItem = {
|
|
26
|
+
label: 'Manual',
|
|
27
|
+
value: 'manual',
|
|
34
28
|
};
|
|
35
29
|
const algorithms = [
|
|
36
|
-
|
|
37
|
-
label: 'Manual',
|
|
38
|
-
value: phaseCorrectionTypes.manual,
|
|
39
|
-
},
|
|
30
|
+
defaultPhasingTypeItem,
|
|
40
31
|
{
|
|
41
32
|
label: 'Automatic',
|
|
42
|
-
value:
|
|
33
|
+
value: 'automatic',
|
|
43
34
|
},
|
|
44
35
|
{
|
|
45
|
-
label: '
|
|
46
|
-
value:
|
|
36
|
+
label: 'Convert to absolute spectrum',
|
|
37
|
+
value: 'absolute',
|
|
47
38
|
},
|
|
48
39
|
];
|
|
49
40
|
const emptyData = { datum: {}, filter: null };
|
|
@@ -56,9 +47,12 @@ export default function PhaseCorrectionPanel() {
|
|
|
56
47
|
const valueRef = useRef({ ph0: 0, ph1: 0 });
|
|
57
48
|
const ph0Ref = useRef();
|
|
58
49
|
const ph1Ref = useRef();
|
|
59
|
-
const
|
|
50
|
+
const { value: phaseCorrectionTypeItem, ...defaultSelectProps } = useSelect({
|
|
51
|
+
defaultSelectedItem: defaultPhasingTypeItem,
|
|
52
|
+
itemTextKey: 'label',
|
|
53
|
+
});
|
|
60
54
|
useEffect(() => {
|
|
61
|
-
if (filter &&
|
|
55
|
+
if (filter && phaseCorrectionTypeItem?.value === 'manual') {
|
|
62
56
|
valueRef.current = filter.value;
|
|
63
57
|
setValue(filter.value);
|
|
64
58
|
}
|
|
@@ -72,23 +66,23 @@ export default function PhaseCorrectionPanel() {
|
|
|
72
66
|
ph1Ref.current.setValue(valueRef.current.ph1);
|
|
73
67
|
}
|
|
74
68
|
}
|
|
75
|
-
}, [filter,
|
|
76
|
-
|
|
77
|
-
switch (
|
|
78
|
-
case
|
|
69
|
+
}, [filter, phaseCorrectionTypeItem]);
|
|
70
|
+
function handleApplyFilter() {
|
|
71
|
+
switch (phaseCorrectionTypeItem?.value) {
|
|
72
|
+
case 'automatic': {
|
|
79
73
|
dispatch({
|
|
80
74
|
type: 'APPLY_AUTO_PHASE_CORRECTION_FILTER',
|
|
81
75
|
});
|
|
82
76
|
break;
|
|
83
77
|
}
|
|
84
|
-
case
|
|
78
|
+
case 'manual': {
|
|
85
79
|
dispatch({
|
|
86
80
|
type: 'APPLY_MANUAL_PHASE_CORRECTION_FILTER',
|
|
87
81
|
payload: value,
|
|
88
82
|
});
|
|
89
83
|
break;
|
|
90
84
|
}
|
|
91
|
-
case
|
|
85
|
+
case 'absolute': {
|
|
92
86
|
dispatch({
|
|
93
87
|
type: 'APPLY_ABSOLUTE_FILTER',
|
|
94
88
|
});
|
|
@@ -97,7 +91,7 @@ export default function PhaseCorrectionPanel() {
|
|
|
97
91
|
default:
|
|
98
92
|
break;
|
|
99
93
|
}
|
|
100
|
-
}
|
|
94
|
+
}
|
|
101
95
|
const calcPhaseCorrectionHandler = useCallback((newValues, filedName) => {
|
|
102
96
|
if (filedName === 'ph1' && data.re) {
|
|
103
97
|
const diff0 = newValues.ph0 - valueRef.current.ph0;
|
|
@@ -134,13 +128,10 @@ export default function PhaseCorrectionPanel() {
|
|
|
134
128
|
valueRef.current = newValue;
|
|
135
129
|
setValue(valueRef.current);
|
|
136
130
|
}, [calcPhaseCorrectionHandler, updateInputRangeInitialValue]);
|
|
137
|
-
|
|
131
|
+
function handleCancelFilter() {
|
|
138
132
|
dispatch({
|
|
139
133
|
type: 'RESET_SELECTED_TOOL',
|
|
140
134
|
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
setPhaseCorrectionType(val);
|
|
144
|
-
}, []);
|
|
145
|
-
return (_jsxs(HeaderContainer, { children: [_jsx(Select, { onChange: onChangeHandler, items: algorithms, defaultValue: phaseCorrectionTypes.manual, style: selectStyle }), phaseCorrectionType === phaseCorrectionTypes.manual && (_jsxs(_Fragment, { children: [_jsx(Label, { title: "PH0 :", style: headerLabelStyle, children: _jsx(Input, { name: "ph0", style: inputStyle, onChange: handleInput, value: value.ph0, type: "number", debounceTime: 250 }) }), _jsx(Label, { title: "PH1 :", style: headerLabelStyle, children: _jsx(Input, { name: "ph1", style: inputStyle, onChange: handleInput, value: value.ph1, type: "number", debounceTime: 250 }) }), _jsx(InputRange, { ref: ph0Ref, name: "ph0", label: "Change PH0 (click and drag)", shortLabel: "Ph0", style: { width: '20%' }, onChange: handleRangeChange }), _jsx(InputRange, { ref: ph1Ref, name: "ph1", label: "Change PH1 (click and drag)", shortLabel: "Ph1", style: { width: '20%' }, onChange: handleRangeChange })] })), _jsx(ActionButtons, { onDone: handleApplyFilter, onCancel: handleCancelFilter })] }));
|
|
135
|
+
}
|
|
136
|
+
return (_jsxs(HeaderContainer, { children: [_jsx("div", { style: { padding: '0 5px' }, children: _jsx(Select, { items: algorithms, filterable: false, itemsEqual: "value", ...defaultSelectProps, children: _jsx(Button, { text: phaseCorrectionTypeItem?.label, rightIcon: "double-caret-vertical" }) }) }), phaseCorrectionTypeItem?.value === 'manual' && (_jsxs(_Fragment, { children: [_jsx(Label, { title: "PH0 :", style: headerLabelStyle, children: _jsx(Input, { name: "ph0", style: inputStyle, onChange: handleInput, value: value.ph0, type: "number", debounceTime: 250 }) }), _jsx(Label, { title: "PH1 :", style: headerLabelStyle, children: _jsx(Input, { name: "ph1", style: inputStyle, onChange: handleInput, value: value.ph1, type: "number", debounceTime: 250 }) }), _jsx(InputRange, { ref: ph0Ref, name: "ph0", label: "Change PH0 (click and drag)", shortLabel: "Ph0", style: { width: '20%' }, onChange: handleRangeChange }), _jsx(InputRange, { ref: ph1Ref, name: "ph1", label: "Change PH1 (click and drag)", shortLabel: "Ph1", style: { width: '20%' }, onChange: handleRangeChange })] })), _jsx(ActionButtons, { onDone: handleApplyFilter, onCancel: handleCancelFilter })] }));
|
|
146
137
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function PhaseCorrectionTwoDimensionsPanel(): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
export default function PhaseCorrectionTwoDimensionsPanel(): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
2
|
-
|
|
3
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { css } from '@emotion/react';
|
|
4
|
+
import debounce from 'lodash/debounce';
|
|
5
|
+
import { Filters } from 'nmr-processing';
|
|
6
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
7
|
+
import { FaRulerHorizontal, FaRulerVertical } from 'react-icons/fa';
|
|
8
|
+
import { MdLooksTwo } from 'react-icons/md';
|
|
9
|
+
import { Toolbar } from 'react-science/ui';
|
|
4
10
|
import { useActivePhaseTraces } from '../2d/1d-tracer/phase-correction-traces/useActivePhaseTraces';
|
|
5
11
|
import { useDispatch } from '../context/DispatchContext';
|
|
6
12
|
import ActionButtons from '../elements/ActionButtons';
|
|
7
13
|
import Input from '../elements/Input';
|
|
8
14
|
import InputRange from '../elements/InputRange';
|
|
9
15
|
import Label from '../elements/Label';
|
|
10
|
-
import
|
|
16
|
+
import { useFilter } from '../hooks/useFilter';
|
|
11
17
|
import useSpectrum from '../hooks/useSpectrum';
|
|
12
18
|
import { headerLabelStyle } from './Header';
|
|
13
19
|
import { HeaderContainer } from './HeaderContainer';
|
|
14
|
-
const selectStyle = {
|
|
15
|
-
marginLeft: '5px',
|
|
16
|
-
marginRight: '10px',
|
|
17
|
-
border: 'none',
|
|
18
|
-
height: '20px',
|
|
19
|
-
};
|
|
20
20
|
const inputStyle = {
|
|
21
21
|
input: {
|
|
22
22
|
width: '70px',
|
|
@@ -26,62 +26,110 @@ const inputStyle = {
|
|
|
26
26
|
height: '100%',
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
|
-
const TRACE_DIRECTIONS = ['horizontal', 'vertical'].map((key) => ({
|
|
30
|
-
label: stringCapitalize(key),
|
|
31
|
-
value: key,
|
|
32
|
-
}));
|
|
33
29
|
const emptyData = { datum: {}, filter: null };
|
|
30
|
+
const defaultPhaseOptions = {
|
|
31
|
+
horizontal: { ph0: 0, ph1: 0 },
|
|
32
|
+
vertical: { ph0: 0, ph1: 0 },
|
|
33
|
+
};
|
|
34
34
|
export default function PhaseCorrectionTwoDimensionsPanel() {
|
|
35
|
-
const {
|
|
35
|
+
const { activeTraceDirection, pivot, addTracesToBothDirections } = useActivePhaseTraces();
|
|
36
36
|
const { data } = useSpectrum(emptyData);
|
|
37
|
-
const
|
|
37
|
+
const filter = useFilter(Filters.phaseCorrectionTwoDimensions.id);
|
|
38
|
+
const debounceCalculation = useRef(debounce((options) => {
|
|
39
|
+
dispatch({
|
|
40
|
+
type: 'CALCULATE_TOW_DIMENSIONS_MANUAL_PHASE_CORRECTION_FILTER',
|
|
41
|
+
payload: { ...options, applyOn2D: true },
|
|
42
|
+
});
|
|
43
|
+
}, 250));
|
|
38
44
|
const dispatch = useDispatch();
|
|
39
|
-
const [value, setValue] = useState(
|
|
40
|
-
const valueRef = useRef(
|
|
45
|
+
const [value, setValue] = useState(defaultPhaseOptions);
|
|
46
|
+
const valueRef = useRef(defaultPhaseOptions);
|
|
41
47
|
const ph0Ref = useRef();
|
|
42
48
|
const ph1Ref = useRef();
|
|
43
49
|
useEffect(() => {
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
if (filter) {
|
|
51
|
+
const { value } = filter;
|
|
52
|
+
const phaseOptions = defaultPhaseOptions;
|
|
53
|
+
for (const direction of Object.keys(value)) {
|
|
54
|
+
const { ph0, ph1 } = value[direction];
|
|
55
|
+
phaseOptions[direction] = { ph0, ph1 };
|
|
56
|
+
}
|
|
57
|
+
setValue(phaseOptions);
|
|
58
|
+
valueRef.current = phaseOptions;
|
|
59
|
+
}
|
|
60
|
+
}, [filter]);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (ph0Ref.current && ph1Ref.current) {
|
|
63
|
+
const { ph0, ph1 } = valueRef.current[activeTraceDirection];
|
|
64
|
+
ph0Ref.current.setValue(ph0);
|
|
65
|
+
ph1Ref.current.setValue(ph1);
|
|
47
66
|
}
|
|
48
|
-
}, [
|
|
49
|
-
const calcPhaseCorrectionHandler = useCallback((
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
67
|
+
}, [activeTraceDirection]);
|
|
68
|
+
const calcPhaseCorrectionHandler = useCallback((inputValue, filedName, source) => {
|
|
69
|
+
const newValue = inputValue[activeTraceDirection];
|
|
70
|
+
if (filedName === 'ph1' && data && pivot) {
|
|
71
|
+
const datum = data.rr;
|
|
72
|
+
const nbPoints = activeTraceDirection === 'horizontal'
|
|
73
|
+
? datum.z[0].length
|
|
74
|
+
: datum.z.length;
|
|
75
|
+
const { ph0, ph1 } = valueRef.current[activeTraceDirection];
|
|
76
|
+
const diff0 = newValue.ph0 - ph0;
|
|
77
|
+
const diff1 = newValue.ph1 - ph1;
|
|
78
|
+
newValue.ph0 += diff0 - (diff1 * (nbPoints - pivot?.index)) / nbPoints;
|
|
55
79
|
}
|
|
56
80
|
dispatch({
|
|
57
81
|
type: 'CALCULATE_TOW_DIMENSIONS_MANUAL_PHASE_CORRECTION_FILTER',
|
|
58
|
-
payload:
|
|
82
|
+
payload: { ...newValue, applyOn2D: source === 'input' },
|
|
59
83
|
});
|
|
60
|
-
|
|
84
|
+
if (source === 'inputRange') {
|
|
85
|
+
debounceCalculation.current(newValue);
|
|
86
|
+
}
|
|
87
|
+
}, [activeTraceDirection, data, dispatch, pivot]);
|
|
61
88
|
const updateInputRangeInitialValue = useCallback((value) => {
|
|
62
89
|
// update InputRange initial value
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
90
|
+
const { ph0, ph1 } = value[activeTraceDirection];
|
|
91
|
+
ph0Ref.current.setValue(ph0);
|
|
92
|
+
ph1Ref.current.setValue(ph1);
|
|
93
|
+
}, [activeTraceDirection]);
|
|
66
94
|
const handleInput = useCallback((e) => {
|
|
67
95
|
const { name, value } = e.target;
|
|
68
96
|
if (e.target) {
|
|
69
|
-
const newValue = {
|
|
97
|
+
const newValue = {
|
|
98
|
+
...valueRef.current,
|
|
99
|
+
[activeTraceDirection]: {
|
|
100
|
+
...valueRef.current[activeTraceDirection],
|
|
101
|
+
[name]: Number(value),
|
|
102
|
+
},
|
|
103
|
+
};
|
|
70
104
|
if (String(value).trim() !== '-') {
|
|
71
|
-
calcPhaseCorrectionHandler(newValue, name);
|
|
105
|
+
calcPhaseCorrectionHandler(newValue, name, 'input');
|
|
72
106
|
}
|
|
73
107
|
updateInputRangeInitialValue(newValue);
|
|
74
108
|
valueRef.current = newValue;
|
|
75
109
|
setValue(valueRef.current);
|
|
76
110
|
}
|
|
77
|
-
}, [
|
|
111
|
+
}, [
|
|
112
|
+
activeTraceDirection,
|
|
113
|
+
calcPhaseCorrectionHandler,
|
|
114
|
+
updateInputRangeInitialValue,
|
|
115
|
+
]);
|
|
78
116
|
const handleRangeChange = useCallback((e) => {
|
|
79
|
-
const newValue = {
|
|
80
|
-
|
|
117
|
+
const newValue = {
|
|
118
|
+
...valueRef.current,
|
|
119
|
+
[activeTraceDirection]: {
|
|
120
|
+
...valueRef.current[activeTraceDirection],
|
|
121
|
+
[e.name]: e.value,
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
calcPhaseCorrectionHandler(newValue, e.name, 'inputRange');
|
|
81
125
|
updateInputRangeInitialValue(newValue);
|
|
82
126
|
valueRef.current = newValue;
|
|
83
127
|
setValue(valueRef.current);
|
|
84
|
-
}, [
|
|
128
|
+
}, [
|
|
129
|
+
activeTraceDirection,
|
|
130
|
+
calcPhaseCorrectionHandler,
|
|
131
|
+
updateInputRangeInitialValue,
|
|
132
|
+
]);
|
|
85
133
|
const handleCancelFilter = useCallback(() => {
|
|
86
134
|
dispatch({
|
|
87
135
|
type: 'RESET_SELECTED_TOOL',
|
|
@@ -93,9 +141,15 @@ export default function PhaseCorrectionTwoDimensionsPanel() {
|
|
|
93
141
|
payload: { direction },
|
|
94
142
|
});
|
|
95
143
|
}
|
|
96
|
-
/*eslint-disable unicorn/consistent-function-scoping */
|
|
97
144
|
function handleApplyFilter() {
|
|
98
|
-
|
|
145
|
+
dispatch({ type: 'APPLY_MANUAL_PHASE_CORRECTION_TOW_DIMENSION_FILTER' });
|
|
146
|
+
}
|
|
147
|
+
function handleToggleAddTraceToBothDirections() {
|
|
148
|
+
dispatch({ type: 'TOGGLE_ADD_PHASE_CORRECTION_TRACE_TO_BOTH_DIRECTIONS' });
|
|
99
149
|
}
|
|
100
|
-
return (_jsxs(HeaderContainer, {
|
|
150
|
+
return (_jsxs(HeaderContainer, { style: { padding: '0 5px' }, children: [_jsx(Label, { title: "Direction :", style: headerLabelStyle, children: _jsxs(Toolbar, { children: [_jsx(Toolbar.Item, { css: css `
|
|
151
|
+
border: 1px solid #f7f7f7;
|
|
152
|
+
`, title: "Horizontal", icon: _jsx(FaRulerHorizontal, {}), active: activeTraceDirection === 'horizontal', onClick: () => onChangeHandler('horizontal') }), _jsx(Toolbar.Item, { css: css `
|
|
153
|
+
border: 1px solid #f7f7f7;
|
|
154
|
+
`, title: "Vertical", icon: _jsx(FaRulerVertical, {}), active: activeTraceDirection === 'vertical', onClick: () => onChangeHandler('vertical') })] }) }), _jsx("div", { style: { paddingRight: '5px' }, children: _jsx(Toolbar, { children: _jsx(Toolbar.Item, { title: "Add the trace in both directions", icon: _jsx(MdLooksTwo, {}), active: addTracesToBothDirections, onClick: handleToggleAddTraceToBothDirections }) }) }), _jsx(Label, { title: "PH0 :", style: headerLabelStyle, children: _jsx(Input, { name: "ph0", style: inputStyle, onChange: handleInput, value: value[activeTraceDirection].ph0, type: "number", debounceTime: 250 }) }), _jsx(Label, { title: "PH1 :", style: headerLabelStyle, children: _jsx(Input, { name: "ph1", style: inputStyle, onChange: handleInput, value: value[activeTraceDirection].ph1, type: "number", debounceTime: 250 }) }), _jsx(InputRange, { ref: ph0Ref, name: "ph0", label: "Change PH0 (click and drag)", shortLabel: "Ph0", style: { width: '20%' }, onChange: handleRangeChange }), _jsx(InputRange, { ref: ph1Ref, name: "ph1", label: "Change PH1 (click and drag)", shortLabel: "Ph1", style: { width: '20%' }, onChange: handleRangeChange }), _jsx(ActionButtons, { onDone: handleApplyFilter, onCancel: handleCancelFilter })] }));
|
|
101
155
|
}
|