nmrium 0.50.0 → 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/README.md +7 -7
- 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/CloseButton.d.ts +2 -2
- package/lib/component/elements/CloseButton.js +1 -1
- package/lib/component/elements/CounterLabel.d.ts +3 -3
- package/lib/component/elements/CounterLabel.js +3 -3
- package/lib/component/elements/PreferencesButton.d.ts +2 -2
- package/lib/component/elements/PreferencesButton.js +2 -4
- package/lib/component/elements/SaveButton.d.ts +2 -2
- package/lib/component/elements/SaveButton.js +1 -1
- package/lib/component/elements/Select.js +2 -2
- package/lib/component/elements/ToolBarButton.d.ts +1 -8
- package/lib/component/elements/ToolBarButton.js +2 -11
- package/lib/component/elements/ToolbarPopoverItem.d.ts +11 -0
- package/lib/component/elements/ToolbarPopoverItem.js +10 -0
- 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/CopyClipboardModal.js +1 -1
- package/lib/component/modal/EditPeakShapeModal.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/aboutUs/AboutUsModal.js +1 -1
- 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/editZone/EditZoneModal.js +1 -1
- 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/AutomaticAssignment.js +16 -2
- package/lib/component/panels/AutomaticAssignment/useAutoAssignments.js +7 -4
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +20 -6
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +16 -3
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +14 -10
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +6 -4
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +48 -14
- package/lib/component/panels/RangesPanel/RangesHeader.js +73 -13
- package/lib/component/panels/RangesPanel/RangesPanel.js +4 -4
- package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +49 -8
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +11 -5
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +1 -1
- package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.js +1 -1
- package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.js +1 -1
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +28 -18
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +28 -4
- package/lib/component/panels/databasePanel/DatabasePanel.js +37 -19
- package/lib/component/panels/databasePanel/DatabaseSearchOptions.d.ts +3 -3
- package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +4 -4
- package/lib/component/panels/filtersPanel/FilterPanel.js +6 -4
- package/lib/component/panels/filtersPanel/FiltersTable.js +27 -23
- package/lib/component/panels/header/DefaultPanelHeader.d.ts +10 -6
- package/lib/component/panels/header/DefaultPanelHeader.js +26 -10
- 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 +36 -7
- 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/panels/spectrumSimulation/SpectrumSimulation.js +5 -1
- 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.d.ts +1 -1
- 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 +241 -8
- package/lib/component/toolbar/toolbarMenu.d.ts +4 -0
- package/lib/component/toolbar/toolbarMenu.js +77 -0
- package/lib/component/utility/Events.d.ts +11 -0
- package/lib/component/utility/Events.js +22 -0
- package/lib/component/utility/booleanToString.d.ts +6 -0
- package/lib/component/utility/booleanToString.js +4 -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/DeleteButton.d.ts +0 -6
- package/lib/component/elements/DeleteButton.js +0 -8
- package/lib/component/elements/DropdownMenu.d.ts +0 -9
- package/lib/component/elements/DropdownMenu.js +0 -7
- package/lib/component/elements/FilterButton.d.ts +0 -6
- package/lib/component/elements/FilterButton.js +0 -8
- 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/panels/PeaksPanel/PeaksToggleActions.d.ts +0 -12
- package/lib/component/panels/PeaksPanel/PeaksToggleActions.js +0 -7
- package/lib/component/reducer/helper/getStrongestPeak.d.ts +0 -7
- package/lib/component/reducer/helper/getStrongestPeak.js +0 -15
- package/lib/component/toolbar/BasicToolBar.d.ts +0 -1
- package/lib/component/toolbar/BasicToolBar.js +0 -165
- package/lib/component/toolbar/FunctionToolBar.d.ts +0 -3
- package/lib/component/toolbar/FunctionToolBar.js +0 -148
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { v4 } from '@lukeed/uuid';
|
|
2
|
+
import { zoomIdentity } from 'd3';
|
|
2
3
|
import { contoursManager } from '../../../data/data2d/Spectrum2D/contours';
|
|
3
4
|
import { getYScale, getXScale } from '../../1d/utilities/scale';
|
|
4
5
|
import { LAYOUT } from '../../2d/utilities/DimensionLayout';
|
|
5
|
-
import { get2DYScale } from '../../2d/utilities/scale';
|
|
6
|
+
import { get2DXScale, get2DYScale } from '../../2d/utilities/scale';
|
|
6
7
|
import { defaultRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
|
|
7
8
|
import { options as Tools } from '../../toolbar/ToolTypes';
|
|
8
9
|
import groupByInfoKey from '../../utility/GroupByInfoKey';
|
|
@@ -168,17 +169,70 @@ function handleBrushEnd(draft, action) {
|
|
|
168
169
|
const domainY = startY > endY ? [endY, startY] : [startY, endY];
|
|
169
170
|
addToBrushHistory(draft, { trackID, xDomain: domainX, yDomain: domainY });
|
|
170
171
|
}
|
|
172
|
+
function zoomWithScroll(draft, options) {
|
|
173
|
+
const { zoomOptions, direction = 'Horizontal', dimension } = options;
|
|
174
|
+
let scaleX;
|
|
175
|
+
let scaleY;
|
|
176
|
+
if (dimension === '1D') {
|
|
177
|
+
scaleX = getXScale(draft);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
scaleX = get2DXScale(draft);
|
|
181
|
+
scaleY = get2DYScale(draft);
|
|
182
|
+
}
|
|
183
|
+
const scaleRatio = toScaleRatio(zoomOptions, { invert: true });
|
|
184
|
+
if (direction === 'Both' || direction === 'Horizontal') {
|
|
185
|
+
const { x } = zoomOptions;
|
|
186
|
+
const domain = zoomIdentity
|
|
187
|
+
.translate(x, 0)
|
|
188
|
+
.scale(scaleRatio)
|
|
189
|
+
.translate(-x, 0)
|
|
190
|
+
.rescaleX(scaleX)
|
|
191
|
+
.domain();
|
|
192
|
+
const { originDomain: { xDomain: [x1, x2], }, } = draft;
|
|
193
|
+
draft.xDomain = [
|
|
194
|
+
domain[0] < x1 ? x1 : domain[0],
|
|
195
|
+
domain[1] > x2 ? x2 : domain[1],
|
|
196
|
+
];
|
|
197
|
+
}
|
|
198
|
+
if (dimension === '2D' &&
|
|
199
|
+
(direction === 'Both' || direction === 'Vertical')) {
|
|
200
|
+
const { y } = zoomOptions;
|
|
201
|
+
const domain = zoomIdentity
|
|
202
|
+
.translate(y, 0)
|
|
203
|
+
.scale(scaleRatio)
|
|
204
|
+
.translate(-y, 0)
|
|
205
|
+
.rescaleX(scaleY)
|
|
206
|
+
.domain();
|
|
207
|
+
const { originDomain: { yDomain: [x1, x2], }, } = draft;
|
|
208
|
+
draft.yDomain = [
|
|
209
|
+
domain[0] < x1 ? x1 : domain[0],
|
|
210
|
+
domain[1] > x2 ? x2 : domain[1],
|
|
211
|
+
];
|
|
212
|
+
}
|
|
213
|
+
}
|
|
171
214
|
function handleZoom(draft, action) {
|
|
172
|
-
const {
|
|
215
|
+
const { options, trackID } = action.payload;
|
|
173
216
|
const { displayerMode, yDomains, toolOptions: { selectedTool }, } = draft;
|
|
174
|
-
const scaleRatio = toScaleRatio(
|
|
217
|
+
const scaleRatio = toScaleRatio(options);
|
|
175
218
|
switch (displayerMode) {
|
|
176
219
|
case '2D': {
|
|
177
|
-
|
|
178
|
-
if (
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
220
|
+
const { shiftKey } = options;
|
|
221
|
+
if (trackID === 'CENTER_2D') {
|
|
222
|
+
// change the vertical scale for traces in 2D phase correction
|
|
223
|
+
if (selectedTool === 'phaseCorrectionTwoDimensions') {
|
|
224
|
+
const { activeTraces } = getTwoDimensionPhaseCorrectionOptions(draft);
|
|
225
|
+
activeTraces.scaleRatio *= scaleRatio;
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
//zoom in/out in 2d
|
|
229
|
+
if (selectedTool === 'zoom' && shiftKey) {
|
|
230
|
+
zoomWithScroll(draft, {
|
|
231
|
+
zoomOptions: options,
|
|
232
|
+
dimension: '2D',
|
|
233
|
+
direction: 'Both',
|
|
234
|
+
});
|
|
235
|
+
}
|
|
182
236
|
}
|
|
183
237
|
else {
|
|
184
238
|
// change the vertical scale of 1D traces
|
|
@@ -187,7 +241,7 @@ function handleZoom(draft, action) {
|
|
|
187
241
|
const id = getSpectrumID(draft, index);
|
|
188
242
|
if (id) {
|
|
189
243
|
const domain = yDomains[id];
|
|
190
|
-
yDomains[id] = wheelZoom(
|
|
244
|
+
yDomains[id] = wheelZoom(options, domain);
|
|
191
245
|
}
|
|
192
246
|
}
|
|
193
247
|
}
|
|
@@ -195,15 +249,21 @@ function handleZoom(draft, action) {
|
|
|
195
249
|
}
|
|
196
250
|
case '1D': {
|
|
197
251
|
const activeSpectra = getActiveSpectra(draft);
|
|
252
|
+
const { shiftKey } = options;
|
|
253
|
+
// Horizontal zoom in/out 1d spectra by mouse wheel
|
|
254
|
+
if (selectedTool === 'zoom' && shiftKey) {
|
|
255
|
+
zoomWithScroll(draft, { zoomOptions: options, dimension: '1D' });
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
198
258
|
if (!activeSpectra) {
|
|
199
259
|
// rescale the spectra
|
|
200
260
|
for (const key of Object.keys(yDomains)) {
|
|
201
261
|
const domain = yDomains[key];
|
|
202
|
-
yDomains[key] = wheelZoom(
|
|
262
|
+
yDomains[key] = wheelZoom(options, domain);
|
|
203
263
|
}
|
|
204
264
|
return;
|
|
205
265
|
}
|
|
206
|
-
if (activeSpectra.length === 1 &&
|
|
266
|
+
if (activeSpectra.length === 1 && shiftKey) {
|
|
207
267
|
switch (selectedTool) {
|
|
208
268
|
case 'rangePicking': {
|
|
209
269
|
setRangesViewProperty(draft, 'integralsScaleRatio', (scale) => scale * scaleRatio);
|
|
@@ -221,7 +281,7 @@ function handleZoom(draft, action) {
|
|
|
221
281
|
for (const activeSpectrum of activeSpectra) {
|
|
222
282
|
const domain = yDomains?.[activeSpectrum?.id];
|
|
223
283
|
if (domain) {
|
|
224
|
-
yDomains[activeSpectrum?.id] = wheelZoom(
|
|
284
|
+
yDomains[activeSpectrum?.id] = wheelZoom(options, domain);
|
|
225
285
|
}
|
|
226
286
|
}
|
|
227
287
|
}
|
|
@@ -252,6 +312,7 @@ function zoomOut(draft, action) {
|
|
|
252
312
|
draft.xDomain = zoomValue.xDomain;
|
|
253
313
|
}
|
|
254
314
|
else {
|
|
315
|
+
draft.xDomain = xDomain;
|
|
255
316
|
setZoom(draft, { scale: 0.8 });
|
|
256
317
|
}
|
|
257
318
|
break;
|
|
@@ -411,7 +472,7 @@ function handelSetActiveTab(draft, action) {
|
|
|
411
472
|
}
|
|
412
473
|
}
|
|
413
474
|
function levelChangeHandler(draft, action) {
|
|
414
|
-
const { deltaY,
|
|
475
|
+
const { deltaY, altKey } = action.payload.options;
|
|
415
476
|
const { data, view: { spectra: { activeTab }, zoom: { levels }, }, } = draft;
|
|
416
477
|
const activeSpectra = getActiveSpectra(draft) || [];
|
|
417
478
|
const activeSpectraObj = {};
|
|
@@ -424,7 +485,7 @@ function levelChangeHandler(draft, action) {
|
|
|
424
485
|
for (const spectrum of spectra) {
|
|
425
486
|
const contourOptions = spectrum.display.contourOptions;
|
|
426
487
|
const zoom = contoursManager(spectrum.id, levels, contourOptions);
|
|
427
|
-
levels[spectrum.id] = zoom.wheel(deltaY,
|
|
488
|
+
levels[spectrum.id] = zoom.wheel(deltaY, altKey);
|
|
428
489
|
}
|
|
429
490
|
}
|
|
430
491
|
catch (error) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Draft } from 'immer';
|
|
2
|
+
import { ZoomOptions } from '../../EventsTrackers/BrushTracker';
|
|
2
3
|
import { State } from '../Reducer';
|
|
3
4
|
export declare const ZOOM_TYPES: {
|
|
4
5
|
readonly HORIZONTAL: "HORIZONTAL";
|
|
@@ -7,12 +8,12 @@ export declare const ZOOM_TYPES: {
|
|
|
7
8
|
readonly FULL: "FULL";
|
|
8
9
|
};
|
|
9
10
|
export type ZoomType = keyof typeof ZOOM_TYPES;
|
|
10
|
-
declare function toScaleRatio(
|
|
11
|
-
interface
|
|
11
|
+
declare function toScaleRatio(options: ZoomOptions, zoomOptions?: ScaleRationOptions): number;
|
|
12
|
+
interface ScaleRationOptions {
|
|
12
13
|
factor?: number;
|
|
13
14
|
invert?: boolean;
|
|
14
15
|
}
|
|
15
|
-
declare function wheelZoom(
|
|
16
|
+
declare function wheelZoom(options: ZoomOptions, domain: number[], scaleOptions?: ScaleRationOptions): number[];
|
|
16
17
|
declare function setZoom(draft: Draft<State>, options?: {
|
|
17
18
|
scale?: number;
|
|
18
19
|
spectrumID?: string;
|
|
@@ -6,15 +6,15 @@ export const ZOOM_TYPES = {
|
|
|
6
6
|
STEP_HORIZONTAL: 'STEP_HORIZONTAL',
|
|
7
7
|
FULL: 'FULL',
|
|
8
8
|
};
|
|
9
|
-
function toScaleRatio(
|
|
9
|
+
function toScaleRatio(options, zoomOptions = {}) {
|
|
10
10
|
const { factor = 1, invert = false } = zoomOptions;
|
|
11
|
-
const deltaY = Math.abs(
|
|
11
|
+
const deltaY = Math.abs(options.deltaY) < 100 ? options.deltaY * 100 : options.deltaY;
|
|
12
12
|
const delta = deltaY * (invert ? -0.001 : 0.001) * factor;
|
|
13
13
|
const ratio = delta < 0 ? -1 / (delta - 1) : 1 + delta;
|
|
14
14
|
return ratio;
|
|
15
15
|
}
|
|
16
|
-
function wheelZoom(
|
|
17
|
-
const ratio = toScaleRatio(
|
|
16
|
+
function wheelZoom(options, domain, scaleOptions = {}) {
|
|
17
|
+
const ratio = toScaleRatio(options, scaleOptions);
|
|
18
18
|
const [min, max] = domain;
|
|
19
19
|
return [min * ratio, max * ratio];
|
|
20
20
|
}
|
|
@@ -32,11 +32,7 @@ function prepareGetLast(historyStack) {
|
|
|
32
32
|
export function addToBrushHistory(draft, options) {
|
|
33
33
|
const { displayerMode } = draft;
|
|
34
34
|
const { trackID, xDomain, yDomain } = options;
|
|
35
|
-
const brushHistory = zoomHistoryManager(
|
|
36
|
-
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
37
|
-
draft.zoom.history,
|
|
38
|
-
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
39
|
-
draft.view.spectra.activeTab);
|
|
35
|
+
const brushHistory = zoomHistoryManager(draft.zoom.history, draft.view.spectra.activeTab);
|
|
40
36
|
if (displayerMode === '2D') {
|
|
41
37
|
switch (trackID) {
|
|
42
38
|
case 'CENTER_2D':
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { xFindClosestIndex } from 'ml-spectra-processing';
|
|
2
|
+
import { maxAbsoluteValue } from '../../utility/maxAbsoluteValue';
|
|
3
|
+
export function findStrongestPeak(data) {
|
|
4
|
+
if (!data)
|
|
5
|
+
return null;
|
|
6
|
+
const maxY = maxAbsoluteValue(data.re);
|
|
7
|
+
const index = xFindClosestIndex(data.re, maxY, { sorted: false });
|
|
8
|
+
return {
|
|
9
|
+
xValue: data.x[index],
|
|
10
|
+
yValue: maxY,
|
|
11
|
+
index,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Draft } from 'immer';
|
|
2
|
-
import type { PhaseCorrectionTraceData, State, TwoDimensionPhaseCorrection } from '../Reducer';
|
|
2
|
+
import type { PhaseCorrectionTraceData, State, TraceDirection, TwoDimensionPhaseCorrection } from '../Reducer';
|
|
3
3
|
export declare function getTwoDimensionPhaseCorrectionOptions(state: Draft<State> | State): Draft<TwoDimensionPhaseCorrection & {
|
|
4
4
|
activeTraces: PhaseCorrectionTraceData;
|
|
5
5
|
}>;
|
|
6
|
+
export declare function useTwoDimensionPhaseCorrectionOptions(direction: TraceDirection): PhaseCorrectionTraceData;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import { useChartData } from '../../context/ChartContext';
|
|
1
2
|
export function getTwoDimensionPhaseCorrectionOptions(state) {
|
|
2
|
-
const { toolOptions: { data: { twoDimensionPhaseCorrection: { traces, activeTraceDirection }, }, }, } = state;
|
|
3
|
+
const { toolOptions: { data: { twoDimensionPhaseCorrection: { traces, activeTraceDirection, addTracesToBothDirections, }, }, }, } = state;
|
|
3
4
|
return {
|
|
4
5
|
activeTraces: traces[activeTraceDirection],
|
|
5
6
|
traces,
|
|
6
7
|
activeTraceDirection,
|
|
8
|
+
addTracesToBothDirections,
|
|
7
9
|
};
|
|
8
10
|
}
|
|
11
|
+
export function useTwoDimensionPhaseCorrectionOptions(direction) {
|
|
12
|
+
const { toolOptions: { data: { twoDimensionPhaseCorrection: { traces }, }, }, } = useChartData();
|
|
13
|
+
return traces[direction];
|
|
14
|
+
}
|
|
@@ -1,14 +1,247 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SvgNmrAlignBottom, SvgNmrAlignCenter, SvgNmrApodization, SvgNmrBaselineCorrection, SvgNmrFourierTransform, SvgNmrIntegrate, SvgNmrMultipleAnalysis, SvgNmrOverlay3, SvgNmrOverlay3Aligned, SvgNmrPeakPicking, SvgNmrPhaseCorrection, SvgNmrRangePicking, SvgNmrRealImag, SvgNmrZeroFilling, } from 'cheminfo-font';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { FaSearchPlus, FaExpand, FaDiceFour, FaFileImport, FaFileExport, } from 'react-icons/fa';
|
|
5
|
+
import { PiKnifeBold } from 'react-icons/pi';
|
|
3
6
|
import { Toolbar } from 'react-science/ui';
|
|
4
7
|
import { useChartData } from '../context/ChartContext';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
import { useDispatch } from '../context/DispatchContext';
|
|
9
|
+
import { useLoader } from '../context/LoaderContext';
|
|
10
|
+
import { ToolbarPopoverItem, } from '../elements/ToolbarPopoverItem';
|
|
11
|
+
import useCheckExperimentalFeature from '../hooks/useCheckExperimentalFeature';
|
|
12
|
+
import { useCheckToolsVisibility, } from '../hooks/useCheckToolsVisibility';
|
|
13
|
+
import useDatumWithSpectraStatistics from '../hooks/useDatumWithSpectraStatistics';
|
|
14
|
+
import { useDialogToggle } from '../hooks/useDialogToggle';
|
|
15
|
+
import useExport from '../hooks/useExport';
|
|
16
|
+
import useToolsFunctions from '../hooks/useToolsFunctions';
|
|
17
|
+
import { useVerticalAlign } from '../hooks/useVerticalAlign';
|
|
18
|
+
import ImportPublicationStringModal from '../modal/ImportPublicationStringModal';
|
|
19
|
+
import { LoadJCAMPModal } from '../modal/LoadJCAMPModal';
|
|
20
|
+
import SaveAsModal from '../modal/SaveAsModal';
|
|
21
|
+
import { MetaImportationModal } from '../modal/metaImportation/MetaImportationModal';
|
|
22
|
+
import { options } from './ToolTypes';
|
|
23
|
+
import { EXPORT_MENU, IMPORT_MENU } from './toolbarMenu';
|
|
24
|
+
function isPopoverToolItem(item) {
|
|
25
|
+
return !!item?.menuItems;
|
|
9
26
|
}
|
|
10
|
-
const MemoizedToolBar = memo(ToolBarInner);
|
|
11
27
|
export default function ToolBar() {
|
|
12
28
|
const { toolOptions: { selectedTool }, } = useChartData();
|
|
13
|
-
|
|
29
|
+
const isButtonVisible = useCheckToolsVisibility();
|
|
30
|
+
const dispatch = useDispatch();
|
|
31
|
+
const { isRealSpectrumShown, changeSpectrumViewHandler, changeDisplayViewModeHandler, alignSpectrumsVerticallyHandler, handleChangeOption, handleFullZoomOut, } = useToolsFunctions();
|
|
32
|
+
const handleChange = useCallback((selectedOption) => {
|
|
33
|
+
handleChangeOption(selectedOption);
|
|
34
|
+
}, [handleChangeOption]);
|
|
35
|
+
const openLoader = useLoader();
|
|
36
|
+
const isExperimentalFeature = useCheckExperimentalFeature();
|
|
37
|
+
const { dialog, closeDialog, openDialog } = useDialogToggle({
|
|
38
|
+
loadJCAMP: false,
|
|
39
|
+
importPublicationString: false,
|
|
40
|
+
metaImportation: false,
|
|
41
|
+
saveAs: false,
|
|
42
|
+
});
|
|
43
|
+
const verticalAlign = useVerticalAlign();
|
|
44
|
+
const { fidCounter, ftCounter } = useDatumWithSpectraStatistics();
|
|
45
|
+
const importMenu = isExperimentalFeature
|
|
46
|
+
? IMPORT_MENU
|
|
47
|
+
: IMPORT_MENU.filter((item) => item.id !== 'importPublicationString');
|
|
48
|
+
const exportMenu = isExperimentalFeature
|
|
49
|
+
? EXPORT_MENU
|
|
50
|
+
: EXPORT_MENU.filter((item) => item.id !== 'nmre');
|
|
51
|
+
const handleOnFFTFilter = useCallback(() => {
|
|
52
|
+
dispatch({
|
|
53
|
+
type: 'APPLY_FFT_FILTER',
|
|
54
|
+
});
|
|
55
|
+
}, [dispatch]);
|
|
56
|
+
const handleFFtDimension1Filter = useCallback(() => {
|
|
57
|
+
dispatch({
|
|
58
|
+
type: 'APPLY_FFT_DIMENSION_1_FILTER',
|
|
59
|
+
});
|
|
60
|
+
}, [dispatch]);
|
|
61
|
+
const handleFFtDimension2Filter = useCallback(() => {
|
|
62
|
+
dispatch({
|
|
63
|
+
type: 'APPLY_FFT_DIMENSION_2_FILTER',
|
|
64
|
+
});
|
|
65
|
+
}, [dispatch]);
|
|
66
|
+
const { saveAsSVGHandler, saveAsPNGHandler, saveAsJSONHandler, saveToClipboardHandler, } = useExport();
|
|
67
|
+
function importHandler(data) {
|
|
68
|
+
switch (data?.id) {
|
|
69
|
+
case 'importFile':
|
|
70
|
+
openLoader();
|
|
71
|
+
break;
|
|
72
|
+
case 'importJDX':
|
|
73
|
+
openDialog('loadJCAMP');
|
|
74
|
+
break;
|
|
75
|
+
case 'importPublicationString':
|
|
76
|
+
openDialog('importPublicationString');
|
|
77
|
+
break;
|
|
78
|
+
case 'importMetaInformation':
|
|
79
|
+
openDialog('metaImportation');
|
|
80
|
+
break;
|
|
81
|
+
default:
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function exportHandler(data) {
|
|
85
|
+
switch (data?.id) {
|
|
86
|
+
case 'svg':
|
|
87
|
+
void saveAsSVGHandler();
|
|
88
|
+
break;
|
|
89
|
+
case 'png':
|
|
90
|
+
void saveAsPNGHandler();
|
|
91
|
+
break;
|
|
92
|
+
case 'json':
|
|
93
|
+
saveAsJSONHandler();
|
|
94
|
+
break;
|
|
95
|
+
case 'advance_save':
|
|
96
|
+
openDialog('saveAs');
|
|
97
|
+
break;
|
|
98
|
+
case 'copy':
|
|
99
|
+
void saveToClipboardHandler();
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const toolItems = [
|
|
106
|
+
{
|
|
107
|
+
id: 'zoom',
|
|
108
|
+
title: options.zoom.label,
|
|
109
|
+
icon: _jsx(FaSearchPlus, {}),
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: 'zoomOut',
|
|
113
|
+
title: 'Horizontal zoom out ( Press f ), Horizontal and Vertical zoom out, double click ( Press ff )',
|
|
114
|
+
onClick: handleFullZoomOut,
|
|
115
|
+
icon: _jsx(FaExpand, {}),
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: 'peakPicking',
|
|
119
|
+
title: `${options.peakPicking.label} ( Press p )`,
|
|
120
|
+
icon: _jsx(SvgNmrPeakPicking, {}),
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: 'integral',
|
|
124
|
+
title: `${options.integral.label} ( Press i )`,
|
|
125
|
+
icon: _jsx(SvgNmrIntegrate, {}),
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
id: 'zonePicking',
|
|
129
|
+
title: `${options.zonePicking.label} ( Press r )`,
|
|
130
|
+
icon: _jsx(FaDiceFour, {}),
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
id: 'slicing',
|
|
134
|
+
title: options.slicing.label,
|
|
135
|
+
icon: _jsx(PiKnifeBold, {}),
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: 'rangePicking',
|
|
139
|
+
title: `${options.rangePicking.label} ( Press r )`,
|
|
140
|
+
icon: _jsx(SvgNmrRangePicking, {}),
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
id: 'multipleSpectraAnalysis',
|
|
144
|
+
title: options.multipleSpectraAnalysis.label,
|
|
145
|
+
icon: _jsx(SvgNmrMultipleAnalysis, {}),
|
|
146
|
+
checkOptions: { checkSpectrumType: false },
|
|
147
|
+
condition: ftCounter > 0,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
id: 'apodization',
|
|
151
|
+
title: `${options.apodization.label} (Press a)`,
|
|
152
|
+
icon: _jsx(SvgNmrApodization, {}),
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
id: 'zeroFilling',
|
|
156
|
+
title: `${options.zeroFilling.label} ( Press z )`,
|
|
157
|
+
icon: _jsx(SvgNmrZeroFilling, {}),
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
id: 'phaseCorrection',
|
|
161
|
+
title: `${options.phaseCorrection.label} ( Press a )`,
|
|
162
|
+
icon: _jsx(SvgNmrPhaseCorrection, {}),
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
id: 'phaseCorrectionTwoDimensions',
|
|
166
|
+
title: `${options.phaseCorrectionTwoDimensions.label} ( Press a )`,
|
|
167
|
+
icon: _jsx(SvgNmrPhaseCorrection, {}),
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
id: 'baselineCorrection',
|
|
171
|
+
title: `${options.baselineCorrection.label} ( Press b )`,
|
|
172
|
+
icon: _jsx(SvgNmrBaselineCorrection, {}),
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
id: 'exclusionZones',
|
|
176
|
+
title: `${options.exclusionZones.label} ( Press e )`,
|
|
177
|
+
icon: _jsx(SvgNmrMultipleAnalysis, {}),
|
|
178
|
+
checkOptions: { checkSpectrumType: false },
|
|
179
|
+
condition: ftCounter > 0,
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
id: 'fft',
|
|
183
|
+
title: `${options.fft.label} ( Press t )`,
|
|
184
|
+
onClick: handleOnFFTFilter,
|
|
185
|
+
icon: _jsx(SvgNmrFourierTransform, {}),
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
id: 'fftDimension1',
|
|
189
|
+
title: options.fftDimension1.label,
|
|
190
|
+
onClick: handleFFtDimension1Filter,
|
|
191
|
+
icon: _jsx(SvgNmrFourierTransform, {}),
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
id: 'fftDimension2',
|
|
195
|
+
title: options.fftDimension2.label,
|
|
196
|
+
onClick: handleFFtDimension2Filter,
|
|
197
|
+
icon: _jsx(SvgNmrFourierTransform, {}),
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
id: 'import',
|
|
201
|
+
title: options.import.label,
|
|
202
|
+
icon: _jsx(FaFileImport, {}),
|
|
203
|
+
menuItems: importMenu,
|
|
204
|
+
onClick: importHandler,
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
id: 'exportAs',
|
|
208
|
+
title: options.exportAs.label,
|
|
209
|
+
icon: _jsx(FaFileExport, {}),
|
|
210
|
+
menuItems: exportMenu,
|
|
211
|
+
onClick: exportHandler,
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
id: 'spectraStackAlignments',
|
|
215
|
+
title: `${options.spectraStackAlignments.label} ( Press s )`,
|
|
216
|
+
icon: verticalAlign === 'stack' ? (_jsx(SvgNmrOverlay3Aligned, {})) : (_jsx(SvgNmrOverlay3, {})),
|
|
217
|
+
condition: ftCounter > 1,
|
|
218
|
+
onClick: changeDisplayViewModeHandler,
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
id: 'realImaginary',
|
|
222
|
+
title: isRealSpectrumShown ? 'Display real ' : 'Display imaginary',
|
|
223
|
+
icon: _jsx(SvgNmrRealImag, {}),
|
|
224
|
+
onClick: changeSpectrumViewHandler,
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
id: 'spectraCenterAlignments',
|
|
228
|
+
title: `Baseline ${verticalAlign === 'bottom' ? 'center' : 'bottom'} ( Press c )`,
|
|
229
|
+
icon: verticalAlign === 'bottom' ? (_jsx(SvgNmrAlignCenter, {})) : (_jsx(SvgNmrAlignBottom, {})),
|
|
230
|
+
condition: ftCounter > 0 || fidCounter > 0,
|
|
231
|
+
onClick: alignSpectrumsVerticallyHandler,
|
|
232
|
+
},
|
|
233
|
+
];
|
|
234
|
+
return (_jsxs(_Fragment, { children: [_jsx(LoadJCAMPModal, { isOpen: dialog.loadJCAMP, onCloseDialog: closeDialog }), _jsx(ImportPublicationStringModal, { isOpen: dialog.importPublicationString, onClose: closeDialog }), _jsx(MetaImportationModal, { isOpen: dialog.metaImportation, onCloseDialog: closeDialog }), _jsx(SaveAsModal, { isOpen: dialog.saveAs, onCloseDialog: closeDialog }), _jsx(Toolbar, { vertical: true, children: toolItems.map((item) => {
|
|
235
|
+
const { id, icon, title, checkOptions, condition } = item;
|
|
236
|
+
const show = isButtonVisible(id, checkOptions) &&
|
|
237
|
+
(condition === undefined || condition);
|
|
238
|
+
if (!show)
|
|
239
|
+
return null;
|
|
240
|
+
if (isPopoverToolItem(item)) {
|
|
241
|
+
const { menuItems, onClick } = item;
|
|
242
|
+
return (_jsx(ToolbarPopoverItem, { options: menuItems, title: title, id: id, active: selectedTool === id, icon: icon, onClick: onClick }, id));
|
|
243
|
+
}
|
|
244
|
+
const { onClick } = item;
|
|
245
|
+
return (_jsx(Toolbar.Item, { onClick: onClick || (() => handleChange(id)), title: title, id: id, active: selectedTool === id, icon: icon }, id));
|
|
246
|
+
}) })] }));
|
|
14
247
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FaCopy, FaDownload, FaFile, FaFileDownload, FaFileImage, } from 'react-icons/fa';
|
|
3
|
+
const IMPORT_MENU = [
|
|
4
|
+
{
|
|
5
|
+
icon: _jsx(FaFile, {}),
|
|
6
|
+
text: 'Import from file system (Press Ctrl + O)',
|
|
7
|
+
data: {
|
|
8
|
+
id: 'importFile',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
icon: _jsx(FaFile, {}),
|
|
13
|
+
text: 'Add JCAMP-DX from URL',
|
|
14
|
+
data: {
|
|
15
|
+
id: 'importJDX',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
icon: _jsx(FaFile, {}),
|
|
20
|
+
text: 'Generate spectrum from publication string',
|
|
21
|
+
data: {
|
|
22
|
+
id: 'importPublicationString',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
icon: _jsx(FaFile, {}),
|
|
27
|
+
text: 'Import meta information',
|
|
28
|
+
data: {
|
|
29
|
+
id: 'importMetaInformation',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
const EXPORT_MENU = [
|
|
34
|
+
{
|
|
35
|
+
icon: _jsx(FaDownload, {}),
|
|
36
|
+
text: 'Export as SVG',
|
|
37
|
+
data: {
|
|
38
|
+
id: 'svg',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
icon: _jsx(FaFileImage, {}),
|
|
43
|
+
text: 'Export as PNG',
|
|
44
|
+
data: {
|
|
45
|
+
id: 'png',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
icon: _jsx(FaFileDownload, {}),
|
|
50
|
+
text: 'Save data ( Press Ctrl + S )',
|
|
51
|
+
data: {
|
|
52
|
+
id: 'json',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
icon: _jsx(FaFileDownload, {}),
|
|
57
|
+
text: 'Save data as ( Press Ctrl + Shift + S )',
|
|
58
|
+
data: {
|
|
59
|
+
id: 'advance_save',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
icon: _jsx(FaFileDownload, {}),
|
|
64
|
+
text: 'Save NMRE data',
|
|
65
|
+
data: {
|
|
66
|
+
id: 'nmre',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
icon: _jsx(FaCopy, {}),
|
|
71
|
+
text: 'Copy image to Clipboard ( Press Ctrl + C )',
|
|
72
|
+
data: {
|
|
73
|
+
id: 'copy',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
export { EXPORT_MENU, IMPORT_MENU };
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import EE from 'eventemitter3';
|
|
2
|
+
import { BrushTrackerContext, ClickOptions } from '../EventsTrackers/BrushTracker';
|
|
2
3
|
declare const Emitter: {
|
|
3
4
|
on: (event: any, fn: any) => EE<string | symbol, any>;
|
|
4
5
|
once: (event: any, fn: any) => EE<string | symbol, any>;
|
|
5
6
|
off: (event: any, fn: any) => EE<string | symbol, any>;
|
|
6
7
|
emit: (event: any, payload: any) => boolean;
|
|
7
8
|
};
|
|
9
|
+
export type EventEmitterClickOptions = ClickOptions & {
|
|
10
|
+
xPPM: number;
|
|
11
|
+
};
|
|
12
|
+
interface UseEventOptions {
|
|
13
|
+
onBrushEnd?: (options: BrushTrackerContext & {
|
|
14
|
+
range: number[];
|
|
15
|
+
}) => void;
|
|
16
|
+
onClick?: (options: EventEmitterClickOptions) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare function useEvent(options: UseEventOptions): void;
|
|
8
19
|
export default Emitter;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import EE from 'eventemitter3';
|
|
2
|
+
import { useEffect } from 'react';
|
|
2
3
|
const eventEmitter = new EE();
|
|
3
4
|
const Emitter = {
|
|
4
5
|
on: (event, fn) => eventEmitter.on(event, fn),
|
|
@@ -7,4 +8,25 @@ const Emitter = {
|
|
|
7
8
|
emit: (event, payload) => eventEmitter.emit(event, payload),
|
|
8
9
|
};
|
|
9
10
|
Object.freeze(Emitter);
|
|
11
|
+
export function useEvent(options) {
|
|
12
|
+
const { onBrushEnd, onClick } = options;
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
function handle(event) {
|
|
15
|
+
onBrushEnd?.(event);
|
|
16
|
+
}
|
|
17
|
+
Emitter.on('brushEnd', handle);
|
|
18
|
+
return () => {
|
|
19
|
+
Emitter.off('brushEnd', handle);
|
|
20
|
+
};
|
|
21
|
+
}, [onBrushEnd]);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
function handle(event) {
|
|
24
|
+
onClick?.(event);
|
|
25
|
+
}
|
|
26
|
+
Emitter.on('mouseClick', handle);
|
|
27
|
+
return () => {
|
|
28
|
+
Emitter.off('mouseClick', handle);
|
|
29
|
+
};
|
|
30
|
+
}, [onClick]);
|
|
31
|
+
}
|
|
10
32
|
export default Emitter;
|