nmrium 0.52.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.
- package/lib/component/1d/Viewer1D.js +48 -17
- package/lib/component/1d/ranges/AssignmentLabel.d.ts +7 -0
- package/lib/component/1d/ranges/AssignmentLabel.js +10 -0
- package/lib/component/1d/ranges/Range.js +15 -6
- package/lib/component/1d/tool/XLabelPointer.js +4 -12
- package/lib/component/2d/tools/XYLabelPointer.js +3 -9
- package/lib/component/context/LoggerContext.js +11 -4
- package/lib/component/elements/CloseButton.d.ts +1 -1
- package/lib/component/elements/CustomToolTip.d.ts +8 -0
- package/lib/component/elements/CustomToolTip.js +107 -0
- package/lib/component/elements/EditableColumn.js +6 -5
- package/lib/component/elements/SaveButton.d.ts +1 -1
- package/lib/component/elements/formik/FormikError.js +2 -4
- package/lib/component/elements/formik/FormikInput.js +2 -2
- package/lib/component/header/Header.js +1 -1
- package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.js +41 -10
- package/lib/component/hooks/useActiveSpectrumRangesViewState.js +1 -0
- package/lib/component/hooks/useActiveSpectrumZonesViewState.js +1 -0
- package/lib/component/hooks/useToolsFunctions.js +7 -1
- package/lib/component/main/NMRiumStateProvider.js +12 -2
- package/lib/component/modal/AboutPredictionModal.js +1 -1
- package/lib/component/modal/AboutSpectrumSimulationModal.js +1 -1
- package/lib/component/modal/CopyClipboardModal.js +1 -1
- package/lib/component/modal/EditPeakShapeModal.js +1 -1
- package/lib/component/modal/ImportPublicationStringModal.d.ts +5 -3
- package/lib/component/modal/ImportPublicationStringModal.js +18 -9
- package/lib/component/modal/PredictSpectraModal.js +1 -1
- package/lib/component/modal/aboutUs/AboutUsModal.js +1 -1
- package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
- package/lib/component/modal/editRange/EditRangeModal.js +1 -1
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +1 -1
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +1 -1
- package/lib/component/modal/editZone/EditZoneModal.js +1 -1
- package/lib/component/modal/setting/GeneralSettings.js +12 -19
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +2 -2
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +2 -2
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +2 -2
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +1 -1
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +5 -5
- package/lib/component/panels/RangesPanel/RangesHeader.js +29 -15
- package/lib/component/panels/RangesPanel/RangesPreferences.js +19 -13
- package/lib/component/panels/RangesPanel/RangesTable.js +1 -1
- package/lib/component/panels/RangesPanel/RangesTableRow.js +2 -1
- package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentColumn.d.ts +7 -0
- package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentColumn.js +16 -0
- package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +22 -8
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +1 -1
- package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.d.ts +5 -5
- package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.js +79 -89
- package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.d.ts +5 -4
- package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.js +66 -98
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +13 -32
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +4 -4
- package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +2 -2
- package/lib/component/panels/header/DefaultPanelHeader.js +2 -2
- package/lib/component/panels/header/PreferencesHeader.js +1 -1
- package/lib/component/panels/header/SpectraAutomaticPickingButton.js +1 -1
- package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +4 -4
- package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +8 -1
- package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +1 -1
- package/lib/component/panels/spectrumSimulation/SpinSystemTable.js +1 -1
- package/lib/component/reducer/Reducer.js +4 -0
- package/lib/component/reducer/actions/FiltersActions.d.ts +3 -2
- package/lib/component/reducer/actions/FiltersActions.js +364 -318
- package/lib/component/reducer/actions/MoleculeActions.js +1 -1
- package/lib/component/reducer/actions/RangesActions.d.ts +9 -5
- package/lib/component/reducer/actions/RangesActions.js +31 -21
- package/lib/component/reducer/actions/SpectraActions.d.ts +5 -4
- package/lib/component/reducer/actions/SpectraActions.js +5 -1
- package/lib/component/reducer/actions/ToolsActions.js +13 -20
- package/lib/component/reducer/preferences/actions/setWorkspace.js +4 -3
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +6 -4
- package/lib/component/toolbar/ToolBar.js +112 -26
- package/lib/component/utility/export.js +1 -1
- package/lib/component/workspaces/workspaceDefaultProperties.js +7 -12
- package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +10 -3
- package/lib/data/data1d/Spectrum1D/get1DColor.js +28 -2
- package/lib/data/data1d/Spectrum1D/index.d.ts +2 -2
- package/lib/data/data1d/Spectrum1D/index.js +2 -2
- package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +50 -0
- package/lib/data/data1d/Spectrum1D/ranges/createRange.js +51 -0
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +2 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +4 -2
- package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +52 -0
- package/lib/data/data1d/Spectrum1D/ranges/resizeRange.js +28 -0
- package/lib/data/data2d/Spectrum2D/get2DColor.d.ts +11 -3
- package/lib/data/data2d/Spectrum2D/get2DColor.js +20 -4
- package/lib/data/data2d/Spectrum2D/getSlice.js +1 -1
- package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts +1 -0
- package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts +1 -0
- package/lib/data/utilities/generateColor.d.ts +7 -3
- package/lib/data/utilities/generateColor.js +5 -17
- package/lib/versionInfo.js +1 -1
- package/package.json +29 -29
- package/lib/component/elements/MolecularFormulaInput.d.ts +0 -6
- package/lib/component/elements/MolecularFormulaInput.js +0 -63
- package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +0 -7
- package/lib/data/data1d/Spectrum1D/ranges/addRange.js +0 -31
- package/lib/data/data1d/Spectrum1D/ranges/changeRange.d.ts +0 -3
- package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +0 -32
|
@@ -280,148 +280,155 @@ function updateView(draft, filterUpdateDomainRules) {
|
|
|
280
280
|
}
|
|
281
281
|
function disableLivePreview(draft, id) {
|
|
282
282
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
283
|
-
if (activeSpectrum) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
break;
|
|
283
|
+
if (!activeSpectrum || !draft.tempData) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const index = activeSpectrum.index;
|
|
287
|
+
const { data } = draft.tempData[index];
|
|
288
|
+
draft.data[index].data = data;
|
|
289
|
+
if (baselineCorrection.id !== id) {
|
|
290
|
+
setDomain(draft);
|
|
291
|
+
}
|
|
292
|
+
// reset default options
|
|
293
|
+
switch (id) {
|
|
294
|
+
case apodization.id: {
|
|
295
|
+
draft.toolOptions.data.apodizationOptions = defaultApodizationOptions;
|
|
296
|
+
break;
|
|
298
297
|
}
|
|
298
|
+
default:
|
|
299
|
+
break;
|
|
299
300
|
}
|
|
300
301
|
}
|
|
301
302
|
//action
|
|
302
303
|
function handleShiftSpectrumAlongXAxis(draft, action) {
|
|
304
|
+
const activeSpectrum = getActiveSpectrum(draft);
|
|
305
|
+
if (!activeSpectrum) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
303
308
|
//apply filter into the spectrum
|
|
304
309
|
const { shift } = action.payload;
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
else {
|
|
320
|
-
updateView(draft, shiftX.DOMAIN_UPDATE_RULES);
|
|
321
|
-
}
|
|
310
|
+
const activeFilterIndex = getActiveFilterIndex(draft);
|
|
311
|
+
const index = activeSpectrum?.index;
|
|
312
|
+
FiltersManager.applyFilter(draft.data[index], [
|
|
313
|
+
{ name: shiftX.id, value: { shift } },
|
|
314
|
+
]);
|
|
315
|
+
if (activeFilterIndex !== -1) {
|
|
316
|
+
rollbackSpectrumByFilter(draft, {
|
|
317
|
+
searchBy: 'name',
|
|
318
|
+
key: shiftX.id,
|
|
319
|
+
triggerSource: 'Apply',
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
updateView(draft, shiftX.DOMAIN_UPDATE_RULES);
|
|
322
324
|
}
|
|
323
325
|
}
|
|
324
326
|
//action
|
|
325
327
|
function handleApplyZeroFillingFilter(draft, action) {
|
|
326
328
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
327
|
-
if (activeSpectrum) {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
329
|
+
if (!activeSpectrum || !draft.tempData) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const activeFilterIndex = getActiveFilterIndex(draft);
|
|
333
|
+
const index = activeSpectrum.index;
|
|
334
|
+
const filters = [
|
|
335
|
+
{
|
|
336
|
+
name: zeroFilling.id,
|
|
337
|
+
value: action.payload.options,
|
|
338
|
+
},
|
|
339
|
+
];
|
|
340
|
+
FiltersManager.applyFilter(draft.tempData[index], filters, {
|
|
341
|
+
filterIndex: activeFilterIndex,
|
|
342
|
+
});
|
|
343
|
+
draft.data[index] = draft.tempData[index];
|
|
344
|
+
if (activeFilterIndex !== -1) {
|
|
345
|
+
rollbackSpectrumByFilter(draft, {
|
|
346
|
+
searchBy: 'name',
|
|
347
|
+
key: zeroFilling.id,
|
|
348
|
+
triggerSource: 'Apply',
|
|
338
349
|
});
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
searchBy: 'name',
|
|
343
|
-
key: zeroFilling.id,
|
|
344
|
-
triggerSource: 'Apply',
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
else {
|
|
348
|
-
updateView(draft, zeroFilling.DOMAIN_UPDATE_RULES);
|
|
349
|
-
}
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
updateView(draft, zeroFilling.DOMAIN_UPDATE_RULES);
|
|
350
353
|
}
|
|
351
354
|
}
|
|
352
355
|
//action
|
|
353
356
|
function handleCalculateZeroFillingFilter(draft, action) {
|
|
354
357
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
355
|
-
if (activeSpectrum) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
358
|
+
if (!activeSpectrum || !draft.tempData) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
const { options, livePreview } = action.payload;
|
|
362
|
+
if (livePreview) {
|
|
363
|
+
const index = activeSpectrum.index;
|
|
364
|
+
const { data: { x, re, im }, filters, info, } = draft.tempData[index];
|
|
365
|
+
const _data = { data: { x, re, im }, filters, info };
|
|
366
|
+
zeroFilling.apply(_data, options);
|
|
367
|
+
const { im: newIm, re: newRe, x: newX } = _data.data;
|
|
368
|
+
const datum = draft.data[index];
|
|
369
|
+
datum.data.x = newX;
|
|
370
|
+
datum.data.im = newIm;
|
|
371
|
+
datum.data.re = newRe;
|
|
372
|
+
draft.xDomain = [newX[0], newX.at(-1)];
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
disableLivePreview(draft, zeroFilling.name);
|
|
372
376
|
}
|
|
373
377
|
}
|
|
374
378
|
//action
|
|
375
379
|
function handleCalculateApodizationFilter(draft, action) {
|
|
376
380
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
377
|
-
if (activeSpectrum) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
381
|
+
if (!activeSpectrum || !draft.tempData) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
const index = activeSpectrum.index;
|
|
385
|
+
const { livePreview, options } = action.payload;
|
|
386
|
+
if (livePreview) {
|
|
387
|
+
const { data: { x, re, im }, info, } = draft.tempData[index];
|
|
388
|
+
const _data = { data: { x, re, im }, info };
|
|
389
|
+
draft.toolOptions.data.apodizationOptions = options;
|
|
390
|
+
apodization.apply(_data, options);
|
|
391
|
+
const { im: newIm, re: newRe } = _data.data;
|
|
392
|
+
const datum = draft.data[index];
|
|
393
|
+
datum.data.im = newIm;
|
|
394
|
+
datum.data.re = newRe;
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
disableLivePreview(draft, apodization.name);
|
|
393
398
|
}
|
|
394
399
|
}
|
|
395
400
|
//action
|
|
396
401
|
function handleApplyApodizationFilter(draft, action) {
|
|
397
402
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
398
|
-
if (activeSpectrum) {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
403
|
+
if (!activeSpectrum || !draft.tempData) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
const index = activeSpectrum.index;
|
|
407
|
+
const activeFilterIndex = getActiveFilterIndex(draft);
|
|
408
|
+
FiltersManager.applyFilter(draft.tempData[index], [
|
|
409
|
+
{
|
|
410
|
+
name: apodization.id,
|
|
411
|
+
value: action.payload.options,
|
|
412
|
+
},
|
|
413
|
+
], { filterIndex: activeFilterIndex });
|
|
414
|
+
draft.data[index] = draft.tempData[index];
|
|
415
|
+
if (activeFilterIndex !== -1) {
|
|
416
|
+
rollbackSpectrumByFilter(draft, {
|
|
417
|
+
searchBy: 'name',
|
|
418
|
+
key: apodization.id,
|
|
419
|
+
triggerSource: 'Apply',
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
updateView(draft, apodization.DOMAIN_UPDATE_RULES);
|
|
418
424
|
}
|
|
419
425
|
}
|
|
420
426
|
//action
|
|
421
427
|
function handleApplyFFTFilter(draft) {
|
|
422
428
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
423
|
-
if (!activeSpectrum)
|
|
429
|
+
if (!activeSpectrum) {
|
|
424
430
|
return;
|
|
431
|
+
}
|
|
425
432
|
const { index } = activeSpectrum;
|
|
426
433
|
const activeFilterIndex = getActiveFilterIndex(draft);
|
|
427
434
|
//apply filter into the spectrum
|
|
@@ -446,8 +453,9 @@ function handleApplyFFTFilter(draft) {
|
|
|
446
453
|
}
|
|
447
454
|
function handleApplyFFtDimension1Filter(draft) {
|
|
448
455
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
449
|
-
if (!activeSpectrum)
|
|
456
|
+
if (!activeSpectrum) {
|
|
450
457
|
return;
|
|
458
|
+
}
|
|
451
459
|
const { index } = activeSpectrum;
|
|
452
460
|
const activeFilterIndex = getActiveFilterIndex(draft);
|
|
453
461
|
//apply filter into the spectrum
|
|
@@ -472,8 +480,9 @@ function handleApplyFFtDimension1Filter(draft) {
|
|
|
472
480
|
}
|
|
473
481
|
function handleApplyFFtDimension2Filter(draft) {
|
|
474
482
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
475
|
-
if (!activeSpectrum)
|
|
483
|
+
if (!activeSpectrum) {
|
|
476
484
|
return;
|
|
485
|
+
}
|
|
477
486
|
const { index } = activeSpectrum;
|
|
478
487
|
const activeFilterIndex = getActiveFilterIndex(draft);
|
|
479
488
|
//apply filter into the spectrum
|
|
@@ -499,60 +508,62 @@ function handleApplyFFtDimension2Filter(draft) {
|
|
|
499
508
|
//action
|
|
500
509
|
function handleApplyManualPhaseCorrectionFilter(draft, action) {
|
|
501
510
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
502
|
-
if (activeSpectrum) {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
511
|
+
if (!activeSpectrum || !draft.tempData) {
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
const { index } = activeSpectrum;
|
|
515
|
+
const { ph0, ph1 } = action.payload;
|
|
516
|
+
draft.data = draft.tempData;
|
|
517
|
+
const activeFilterIndex = getActiveFilterIndex(draft);
|
|
518
|
+
FiltersManager.applyFilter(draft.tempData[index], [
|
|
519
|
+
{
|
|
520
|
+
name: phaseCorrection.id,
|
|
521
|
+
value: { ph0, ph1 },
|
|
522
|
+
},
|
|
523
|
+
], { filterIndex: activeFilterIndex });
|
|
524
|
+
draft.data[index] = draft.tempData[index];
|
|
525
|
+
if (activeFilterIndex !== -1) {
|
|
526
|
+
rollbackSpectrumByFilter(draft, {
|
|
527
|
+
searchBy: 'name',
|
|
528
|
+
key: phaseCorrection.id,
|
|
529
|
+
triggerSource: 'Apply',
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
updateView(draft, phaseCorrection.DOMAIN_UPDATE_RULES);
|
|
524
534
|
}
|
|
525
535
|
}
|
|
526
536
|
//action
|
|
527
537
|
function handleAddPhaseCorrectionTrace(draft, action) {
|
|
528
|
-
const { x, y } = action.payload;
|
|
529
538
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
539
|
+
if (!activeSpectrum) {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
const { x, y } = action.payload;
|
|
530
543
|
const { margin, width, height, xDomain, yDomain, mode, data: spectra, } = draft;
|
|
531
544
|
const { activeTraces, traces, addTracesToBothDirections } = getTwoDimensionPhaseCorrectionOptions(draft);
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
traces[direction].spectra.push({
|
|
542
|
-
id: v4(),
|
|
543
|
-
x: xPPM,
|
|
544
|
-
y: yPPM,
|
|
545
|
-
});
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
else {
|
|
549
|
-
activeTraces.spectra.push({
|
|
545
|
+
const spectrum = spectra[activeSpectrum.index];
|
|
546
|
+
if (isSpectrum2D(spectrum)) {
|
|
547
|
+
const scale2dX = get2DXScale({ margin, width, xDomain, mode });
|
|
548
|
+
const scale2dY = get2DYScale({ margin, height, yDomain });
|
|
549
|
+
const xPPM = scale2dX.invert(x);
|
|
550
|
+
const yPPM = scale2dY.invert(y);
|
|
551
|
+
if (addTracesToBothDirections) {
|
|
552
|
+
for (const direction of Object.keys(traces)) {
|
|
553
|
+
traces[direction].spectra.push({
|
|
550
554
|
id: v4(),
|
|
551
555
|
x: xPPM,
|
|
552
556
|
y: yPPM,
|
|
553
557
|
});
|
|
554
558
|
}
|
|
555
559
|
}
|
|
560
|
+
else {
|
|
561
|
+
activeTraces.spectra.push({
|
|
562
|
+
id: v4(),
|
|
563
|
+
x: xPPM,
|
|
564
|
+
y: yPPM,
|
|
565
|
+
});
|
|
566
|
+
}
|
|
556
567
|
}
|
|
557
568
|
}
|
|
558
569
|
//action
|
|
@@ -576,123 +587,128 @@ function handleDeletePhaseCorrectionTrace(draft, action) {
|
|
|
576
587
|
//action
|
|
577
588
|
function handleCalculateManualPhaseCorrection(draft, action) {
|
|
578
589
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
579
|
-
if (activeSpectrum) {
|
|
580
|
-
|
|
581
|
-
const { data: { x, re, im }, info, } = draft.tempData[index];
|
|
582
|
-
const { ph0, ph1 } = action.payload;
|
|
583
|
-
const _data = { data: { x, re, im }, info };
|
|
584
|
-
phaseCorrection.apply(_data, { ph0, ph1 });
|
|
585
|
-
const { im: newIm, re: newRe } = _data.data;
|
|
586
|
-
const datum = draft.data[index];
|
|
587
|
-
datum.data.im = newIm;
|
|
588
|
-
datum.data.re = newRe;
|
|
590
|
+
if (!activeSpectrum || !draft.tempData) {
|
|
591
|
+
return;
|
|
589
592
|
}
|
|
593
|
+
const { index } = activeSpectrum;
|
|
594
|
+
const { data: { x, re, im }, info, } = draft.tempData[index];
|
|
595
|
+
const { ph0, ph1 } = action.payload;
|
|
596
|
+
const _data = { data: { x, re, im }, info };
|
|
597
|
+
phaseCorrection.apply(_data, { ph0, ph1 });
|
|
598
|
+
const { im: newIm, re: newRe } = _data.data;
|
|
599
|
+
const datum = draft.data[index];
|
|
600
|
+
datum.data.im = newIm;
|
|
601
|
+
datum.data.re = newRe;
|
|
590
602
|
}
|
|
591
603
|
//action
|
|
592
604
|
function handleApplyAbsoluteFilter(draft) {
|
|
593
605
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
594
|
-
if (activeSpectrum) {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
606
|
+
if (!activeSpectrum || !draft.tempData) {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
const { index } = activeSpectrum;
|
|
610
|
+
const activeFilterIndex = getActiveFilterIndex(draft);
|
|
611
|
+
FiltersManager.applyFilter(draft.tempData[index], [
|
|
612
|
+
{
|
|
613
|
+
name: phaseCorrection.id,
|
|
614
|
+
value: { absolute: true },
|
|
615
|
+
},
|
|
616
|
+
], { filterIndex: activeFilterIndex });
|
|
617
|
+
draft.data[index] = draft.tempData[index];
|
|
618
|
+
if (activeFilterIndex !== -1) {
|
|
619
|
+
rollbackSpectrumByFilter(draft, {
|
|
620
|
+
searchBy: 'name',
|
|
621
|
+
key: phaseCorrection.id,
|
|
622
|
+
triggerSource: 'Apply',
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
else {
|
|
626
|
+
updateView(draft, phaseCorrection.DOMAIN_UPDATE_RULES);
|
|
614
627
|
}
|
|
615
628
|
}
|
|
616
629
|
//action
|
|
617
630
|
function handleApplyAutoPhaseCorrectionFilter(draft) {
|
|
618
631
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
619
|
-
if (activeSpectrum) {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
632
|
+
if (!activeSpectrum || !draft.tempData) {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
const { index } = activeSpectrum;
|
|
636
|
+
const activeFilterIndex = getActiveFilterIndex(draft);
|
|
637
|
+
FiltersManager.applyFilter(draft.tempData[index], [
|
|
638
|
+
{
|
|
639
|
+
name: phaseCorrection.id,
|
|
640
|
+
value: {},
|
|
641
|
+
},
|
|
642
|
+
], { filterIndex: activeFilterIndex });
|
|
643
|
+
draft.data[index] = draft.tempData[index];
|
|
644
|
+
if (activeFilterIndex !== -1) {
|
|
645
|
+
rollbackSpectrumByFilter(draft, {
|
|
646
|
+
searchBy: 'name',
|
|
647
|
+
key: phaseCorrection.id,
|
|
648
|
+
triggerSource: 'Apply',
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
else {
|
|
652
|
+
updateView(draft, phaseCorrection.DOMAIN_UPDATE_RULES);
|
|
639
653
|
}
|
|
640
654
|
}
|
|
641
655
|
//action
|
|
642
656
|
function handleBaseLineCorrectionFilter(draft, action) {
|
|
643
657
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
644
|
-
if (activeSpectrum) {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
658
|
+
if (!activeSpectrum || !draft.tempData) {
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
const { index } = activeSpectrum;
|
|
662
|
+
const { zones } = draft.toolOptions.data.baselineCorrection;
|
|
663
|
+
const { options } = action.payload;
|
|
664
|
+
const activeFilterIndex = getActiveFilterIndex(draft);
|
|
665
|
+
FiltersManager.applyFilter(draft.tempData[index], [
|
|
666
|
+
{
|
|
667
|
+
name: baselineCorrection.id,
|
|
668
|
+
value: {
|
|
669
|
+
...options,
|
|
670
|
+
zones,
|
|
656
671
|
},
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
672
|
+
},
|
|
673
|
+
], { filterIndex: activeFilterIndex });
|
|
674
|
+
draft.data[index] = draft.tempData[index];
|
|
675
|
+
if (activeFilterIndex !== -1) {
|
|
676
|
+
rollbackSpectrumByFilter(draft, {
|
|
677
|
+
searchBy: 'name',
|
|
678
|
+
key: baselineCorrection.id,
|
|
679
|
+
triggerSource: 'Apply',
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
else {
|
|
683
|
+
updateView(draft, baselineCorrection.DOMAIN_UPDATE_RULES);
|
|
669
684
|
}
|
|
670
685
|
}
|
|
671
686
|
function calculateBaseLineCorrection(draft, baseLineOptions) {
|
|
672
687
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
673
|
-
if (activeSpectrum) {
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
688
|
+
if (!activeSpectrum || !draft.tempData) {
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
const { index } = activeSpectrum;
|
|
692
|
+
const { data: { x, re, im }, info, } = draft.tempData[index];
|
|
693
|
+
// save the baseline options temporary
|
|
694
|
+
draft.toolOptions.data.baselineCorrection = {
|
|
695
|
+
...draft.toolOptions.data.baselineCorrection,
|
|
696
|
+
...(baseLineOptions && baseLineOptions),
|
|
697
|
+
};
|
|
698
|
+
const { zones, options, livePreview } = current(draft).toolOptions.data.baselineCorrection;
|
|
699
|
+
if (livePreview) {
|
|
700
|
+
const _data = { data: { x, re, im }, info };
|
|
701
|
+
baselineCorrection.apply(_data, {
|
|
702
|
+
zones,
|
|
703
|
+
...options,
|
|
704
|
+
});
|
|
705
|
+
const { im: newIm, re: newRe } = _data.data;
|
|
706
|
+
const datum = draft.data[index];
|
|
707
|
+
datum.data.im = newIm;
|
|
708
|
+
datum.data.re = newRe;
|
|
709
|
+
}
|
|
710
|
+
else {
|
|
711
|
+
disableLivePreview(draft, baselineCorrection.id);
|
|
696
712
|
}
|
|
697
713
|
}
|
|
698
714
|
//action
|
|
@@ -701,34 +717,36 @@ function handleCalculateBaseLineCorrection(draft, action) {
|
|
|
701
717
|
}
|
|
702
718
|
//action
|
|
703
719
|
function handleEnableFilter(draft, action) {
|
|
704
|
-
const { id: filterID, enabled } = action.payload;
|
|
705
720
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
706
|
-
if (activeSpectrum) {
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
721
|
+
if (!activeSpectrum) {
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
const { id: filterID, enabled } = action.payload;
|
|
725
|
+
//apply filter into the spectrum
|
|
726
|
+
FiltersManager.enableFilter(draft.data[activeSpectrum.index], filterID, enabled);
|
|
727
|
+
resetSelectedTool(draft);
|
|
728
|
+
setDomain(draft);
|
|
729
|
+
setMode(draft);
|
|
730
|
+
const zoomHistory = zoomHistoryManager(draft.zoom.history, draft.view.spectra.activeTab);
|
|
731
|
+
const zoomValue = zoomHistory.getLast();
|
|
732
|
+
if (zoomValue) {
|
|
733
|
+
draft.xDomain = zoomValue.xDomain;
|
|
734
|
+
draft.yDomain = zoomValue.yDomain;
|
|
718
735
|
}
|
|
719
736
|
}
|
|
720
737
|
//action
|
|
721
738
|
function handleDeleteFilter(draft, action) {
|
|
722
|
-
const filterID = action?.payload?.id;
|
|
723
739
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
724
|
-
if (activeSpectrum) {
|
|
725
|
-
|
|
726
|
-
FiltersManager.deleteFilter(draft.data[activeSpectrum.index], filterID);
|
|
727
|
-
draft.toolOptions.data.activeFilterID = null;
|
|
728
|
-
resetSelectedTool(draft);
|
|
729
|
-
setDomain(draft);
|
|
730
|
-
setMode(draft);
|
|
740
|
+
if (!activeSpectrum) {
|
|
741
|
+
return;
|
|
731
742
|
}
|
|
743
|
+
const filterID = action?.payload?.id;
|
|
744
|
+
//apply filter into the spectrum
|
|
745
|
+
FiltersManager.deleteFilter(draft.data[activeSpectrum.index], filterID);
|
|
746
|
+
draft.toolOptions.data.activeFilterID = null;
|
|
747
|
+
resetSelectedTool(draft);
|
|
748
|
+
setDomain(draft);
|
|
749
|
+
setMode(draft);
|
|
732
750
|
}
|
|
733
751
|
//action
|
|
734
752
|
function handleDeleteSpectraFilter(draft, action) {
|
|
@@ -847,35 +865,36 @@ function handleSetOneDimensionPhaseCorrectionPivotPoint(draft, action) {
|
|
|
847
865
|
}
|
|
848
866
|
}
|
|
849
867
|
function handleSetTwoDimensionPhaseCorrectionPivotPoint(draft, action) {
|
|
868
|
+
const activeSpectrum = getActiveSpectrum(draft);
|
|
869
|
+
if (!activeSpectrum) {
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
850
872
|
const { data: spectra, margin, width, height, yDomain, xDomain, mode, } = draft;
|
|
851
873
|
const { x, y } = action.payload;
|
|
852
874
|
const { activeTraces, activeTraceDirection } = getTwoDimensionPhaseCorrectionOptions(draft);
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
default:
|
|
877
|
-
break;
|
|
878
|
-
}
|
|
875
|
+
switch (activeTraceDirection) {
|
|
876
|
+
case 'horizontal':
|
|
877
|
+
{
|
|
878
|
+
const scale = get2DXScale({ margin, width, xDomain, mode });
|
|
879
|
+
const pivotValue = scale.invert(x);
|
|
880
|
+
const spectrum = spectra[activeSpectrum.index];
|
|
881
|
+
const datum = getProjection(spectrum.data.rr, 0);
|
|
882
|
+
const index = xFindClosestIndex(datum.x, pivotValue);
|
|
883
|
+
activeTraces.pivot = { value: pivotValue, index };
|
|
884
|
+
}
|
|
885
|
+
break;
|
|
886
|
+
case 'vertical':
|
|
887
|
+
{
|
|
888
|
+
const scale = get2DYScale({ margin, height, yDomain });
|
|
889
|
+
const pivotValue = scale.invert(y);
|
|
890
|
+
const spectrum = spectra[activeSpectrum.index];
|
|
891
|
+
const datum = getProjection(spectrum.data.rr, 1);
|
|
892
|
+
const index = xFindClosestIndex(datum.x, pivotValue);
|
|
893
|
+
activeTraces.pivot = { value: pivotValue, index };
|
|
894
|
+
}
|
|
895
|
+
break;
|
|
896
|
+
default:
|
|
897
|
+
break;
|
|
879
898
|
}
|
|
880
899
|
}
|
|
881
900
|
//action
|
|
@@ -919,28 +938,55 @@ function getTwoDimensionsPhaseCorrectionOptions(draft) {
|
|
|
919
938
|
//action
|
|
920
939
|
function handleApplyManualTowDimensionsPhaseCorrectionFilter(draft) {
|
|
921
940
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
922
|
-
if (activeSpectrum) {
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
941
|
+
if (!activeSpectrum || !draft.tempData) {
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
const { index } = activeSpectrum;
|
|
945
|
+
draft.data = draft.tempData;
|
|
946
|
+
const activeFilterIndex = getActiveFilterIndex(draft);
|
|
947
|
+
const filterOptions = getTwoDimensionsPhaseCorrectionOptions(draft);
|
|
948
|
+
FiltersManager.applyFilter(draft.tempData[index], [
|
|
949
|
+
{
|
|
950
|
+
name: phaseCorrectionTwoDimensions.id,
|
|
951
|
+
value: filterOptions,
|
|
952
|
+
},
|
|
953
|
+
], { filterIndex: activeFilterIndex });
|
|
954
|
+
draft.data[index] = draft.tempData[index];
|
|
955
|
+
if (activeFilterIndex !== -1) {
|
|
956
|
+
rollbackSpectrumByFilter(draft, {
|
|
957
|
+
searchBy: 'name',
|
|
958
|
+
key: phaseCorrectionTwoDimensions.id,
|
|
959
|
+
triggerSource: 'Apply',
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
else {
|
|
963
|
+
updateView(draft, phaseCorrectionTwoDimensions.DOMAIN_UPDATE_RULES);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
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);
|
|
944
990
|
}
|
|
945
991
|
}
|
|
946
|
-
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, };
|
|
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, };
|