nmrium 0.54.0 → 0.56.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 +3 -1
- package/lib/component/1d/Viewer1D.js +36 -11
- package/lib/component/1d/XAxis.js +1 -1
- package/lib/component/1d/integral/IntegralsSeries.js +2 -2
- package/lib/component/1d/integral/Integration.d.ts +3 -1
- package/lib/component/1d/integral/Integration.js +3 -2
- package/lib/component/1d/matrix/Boxplot.d.ts +6 -0
- package/lib/component/1d/matrix/Boxplot.js +97 -0
- package/lib/component/1d/matrix/Stocsy.d.ts +5 -0
- package/lib/component/1d/matrix/Stocsy.js +101 -0
- package/lib/component/1d/matrix/useMatrix.d.ts +29 -0
- package/lib/component/1d/matrix/useMatrix.js +93 -0
- package/lib/component/1d/peaks/PeakEditionManager.js +5 -3
- package/lib/component/1d/ranges/AssignmentActionsButtons.d.ts +1 -0
- package/lib/component/1d/ranges/AssignmentActionsButtons.js +3 -3
- package/lib/component/1d/ranges/AssignmentLabel.d.ts +1 -1
- package/lib/component/1d/ranges/AssignmentLabel.js +31 -4
- package/lib/component/1d/ranges/Atoms.js +4 -5
- package/lib/component/1d/ranges/Range.js +48 -6
- package/lib/component/1d/ranges/Ranges.js +2 -1
- package/lib/component/1d/ranges/RangesIntegrals.js +11 -4
- package/lib/component/1d/utilities/scale.d.ts +2 -1
- package/lib/component/1d/utilities/scale.js +6 -1
- package/lib/component/1d-2d/FieldEdition.d.ts +13 -0
- package/lib/component/1d-2d/FieldEdition.js +42 -0
- package/lib/component/2d/Chart2D.js +5 -3
- package/lib/component/2d/zones/Zone.js +18 -2
- package/lib/component/2d/zones/ZonesAssignmentsLabels.d.ts +7 -0
- package/lib/component/2d/zones/ZonesAssignmentsLabels.js +286 -0
- package/lib/component/EventsTrackers/KeysListenerTracker.js +14 -1
- package/lib/component/context/PrepareExportContext.d.ts +21 -0
- package/lib/component/context/PrepareExportContext.js +124 -0
- package/lib/component/context/ShareDataContext.d.ts +10 -0
- package/lib/component/context/ShareDataContext.js +22 -0
- package/lib/component/elements/ActionsButtonsPopover.d.ts +10 -0
- package/lib/component/elements/ActionsButtonsPopover.js +22 -0
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +7 -5
- package/lib/component/elements/ReactTable/ReactTable.d.ts +2 -2
- package/lib/component/elements/SVGButton.d.ts +14 -0
- package/lib/component/elements/SVGButton.js +6 -0
- package/lib/component/elements/SVGGroup.js +15 -13
- package/lib/component/elements/SVGText.d.ts +8 -0
- package/lib/component/elements/SVGText.js +24 -0
- package/lib/component/elements/draggable/SVGDraggable.d.ts +2 -2
- package/lib/component/elements/formik/FormikInput.d.ts +2 -1
- package/lib/component/elements/formik/FormikInput.js +4 -3
- package/lib/component/header/Header.js +7 -10
- package/lib/component/hooks/useActiveSpectrumZonesViewState.js +1 -0
- package/lib/component/hooks/useCheckPointsNumberInWindowArea.d.ts +1 -1
- package/lib/component/hooks/useExport.d.ts +1 -1
- package/lib/component/hooks/useExport.js +4 -4
- package/lib/component/hooks/useFormatNumberByNucleus.d.ts +1 -1
- package/lib/component/hooks/useFormatNumberByNucleus.js +8 -7
- package/lib/component/hooks/useIntegralPath.d.ts +2 -0
- package/lib/component/hooks/useIntegralPath.js +3 -1
- package/lib/component/hooks/usePanelPreferences.d.ts +2 -3
- package/lib/component/hooks/usePanelPreferences.js +4 -3
- package/lib/component/hooks/useSaveSettings.js +7 -14
- package/lib/component/hooks/useToggleSpectraVisibility.d.ts +10 -0
- package/lib/component/hooks/useToggleSpectraVisibility.js +41 -0
- package/lib/component/hooks/useTriggerNewAssignmentLabel.d.ts +4 -0
- package/lib/component/hooks/useTriggerNewAssignmentLabel.js +8 -0
- package/lib/component/hooks/useWorkspaceAction.d.ts +7 -0
- package/lib/component/hooks/useWorkspaceAction.js +89 -0
- package/lib/component/loader/DropZone.js +0 -3
- package/lib/component/main/InnerNMRium.js +3 -1
- package/lib/component/main/InnerNMRiumContents.js +14 -2
- package/lib/component/main/NMRiumStateProvider.js +4 -2
- package/lib/component/modal/editRange/forms/components/DeltaInput.js +3 -3
- package/lib/component/modal/editRange/forms/components/NewSignalTab.js +17 -12
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +30 -13
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +26 -16
- package/lib/component/modal/setting/GeneralSettings.js +7 -21
- package/lib/component/modal/setting/WorkspaceItem.js +1 -1
- package/lib/component/modal/setting/settings-tabs/NucleiTabContent.d.ts +2 -0
- package/lib/component/modal/setting/settings-tabs/NucleiTabContent.js +99 -0
- package/lib/component/modal/setting/settingsValidation.js +36 -40
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.d.ts +2 -2
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +121 -36
- package/lib/component/panels/Panels.js +1 -1
- package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +4 -27
- package/lib/component/panels/SpectraPanel/SpectraPreferences.js +13 -1
- package/lib/component/panels/SpectraPanel/base/setting/PlotChart.js +1 -1
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DHistogram.js +1 -1
- package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentLabelColumn.d.ts +6 -0
- package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentLabelColumn.js +16 -0
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +18 -2
- package/lib/component/panels/ZonesPanel/ZonesPreferences.js +15 -9
- package/lib/component/panels/ZonesPanel/ZonesTable.js +2 -2
- package/lib/component/panels/ZonesPanel/ZonesTableRow.js +3 -2
- package/lib/component/panels/databasePanel/DatabaseTable.js +2 -2
- package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +1 -1
- package/lib/component/reducer/IgnoreActions.js +1 -0
- package/lib/component/reducer/Reducer.d.ts +6 -0
- package/lib/component/reducer/Reducer.js +6 -0
- package/lib/component/reducer/actions/DomainActions.d.ts +12 -4
- package/lib/component/reducer/actions/DomainActions.js +35 -5
- package/lib/component/reducer/actions/FiltersActions.js +2 -2
- package/lib/component/reducer/actions/LoadActions.js +5 -2
- package/lib/component/reducer/actions/RangesActions.js +12 -6
- package/lib/component/reducer/actions/SpectraActions.d.ts +1 -0
- package/lib/component/reducer/actions/SpectraActions.js +7 -2
- package/lib/component/reducer/actions/ZonesActions.d.ts +15 -2
- package/lib/component/reducer/actions/ZonesActions.js +47 -13
- package/lib/component/reducer/helper/setRangesViewProperty.d.ts +1 -0
- package/lib/component/reducer/helper/setRangesViewProperty.js +11 -11
- package/lib/component/reducer/preferences/actions/addWorkspace.js +4 -23
- package/lib/component/reducer/preferences/actions/analyzeSpectra.js +4 -4
- package/lib/component/reducer/preferences/actions/initPreferences.js +2 -4
- package/lib/component/reducer/preferences/actions/matrixGeneration.d.ts +47 -2
- package/lib/component/reducer/preferences/actions/matrixGeneration.js +63 -26
- package/lib/component/reducer/preferences/actions/removeWorkspace.js +0 -5
- package/lib/component/reducer/preferences/actions/setActiveWorkspace.js +0 -4
- package/lib/component/reducer/preferences/actions/setPanelsPreferences.js +1 -1
- package/lib/component/reducer/preferences/actions/setPreferences.js +2 -16
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.d.ts +5 -2
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +17 -1
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +9 -25
- package/lib/component/reducer/preferences/preferencesReducer.js +28 -19
- package/lib/component/toolbar/ToolBar.js +23 -20
- package/lib/component/utility/PathBuilder.d.ts +1 -0
- package/lib/component/utility/PathBuilder.js +8 -1
- package/lib/component/utility/PreferencesHelper.js +5 -4
- package/lib/component/utility/export.js +4 -0
- package/lib/component/workspaces/assignment.js +0 -1
- package/lib/component/workspaces/basic.js +0 -1
- package/lib/component/workspaces/embedded.js +0 -1
- package/lib/component/workspaces/exercise.js +26 -29
- package/lib/component/workspaces/prediction.js +171 -174
- package/lib/component/workspaces/process1D.js +0 -1
- package/lib/component/workspaces/simulation.js +35 -38
- package/lib/component/workspaces/workspaceDefaultProperties.js +9 -11
- package/lib/data/types/common/DeepPartial.d.ts +3 -0
- package/lib/data/types/common/DeepPartial.js +1 -0
- package/lib/versionInfo.js +1 -1
- package/package.json +39 -39
- package/lib/component/elements/CustomToolTip.d.ts +0 -8
- package/lib/component/elements/CustomToolTip.js +0 -107
- package/lib/component/modal/setting/settings-tabs/FormattingTabContent.d.ts +0 -2
- package/lib/component/modal/setting/settings-tabs/FormattingTabContent.js +0 -80
- package/lib/component/reducer/preferences/utilities/mapNucleiFormatting.d.ts +0 -2
- package/lib/component/reducer/preferences/utilities/mapNucleiFormatting.js +0 -10
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
|
+
import { LuUnlink, LuLink } from 'react-icons/lu';
|
|
5
|
+
import { PiTextTBold, PiTextTSlashBold } from 'react-icons/pi';
|
|
4
6
|
import { isSpectrum1D, resizeRange } from '../../../data/data1d/Spectrum1D';
|
|
5
7
|
import { isRangeAssigned } from '../../../data/data1d/Spectrum1D/isRangeAssigned';
|
|
6
8
|
import { checkRangeKind } from '../../../data/utilities/RangeUtilities';
|
|
@@ -8,6 +10,8 @@ import { useAssignment, useAssignmentData, } from '../../assignment/AssignmentsC
|
|
|
8
10
|
import { filterForIDsWithAssignment } from '../../assignment/utilities/filterForIDsWithAssignment';
|
|
9
11
|
import { useDispatch } from '../../context/DispatchContext';
|
|
10
12
|
import { useLogger } from '../../context/LoggerContext';
|
|
13
|
+
import { useShareData } from '../../context/ShareDataContext';
|
|
14
|
+
import { ActionsButtonsPopover, } from '../../elements/ActionsButtonsPopover';
|
|
11
15
|
import { ResizerWithScale } from '../../elements/ResizerWithScale';
|
|
12
16
|
import { HighlightEventSource, useHighlight } from '../../highlight';
|
|
13
17
|
import { useActiveSpectrumRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
|
|
@@ -16,7 +20,6 @@ import useSpectrum from '../../hooks/useSpectrum';
|
|
|
16
20
|
import { options } from '../../toolbar/ToolTypes';
|
|
17
21
|
import { IntegralIndicator } from '../integral/IntegralIndicator';
|
|
18
22
|
import { useScaleX } from '../utilities/scale';
|
|
19
|
-
import { AssignmentActionsButtons } from './AssignmentActionsButtons';
|
|
20
23
|
import { AssignmentLabel } from './AssignmentLabel';
|
|
21
24
|
import { Atoms } from './Atoms';
|
|
22
25
|
const style = css `
|
|
@@ -31,7 +34,7 @@ const style = css `
|
|
|
31
34
|
}
|
|
32
35
|
`;
|
|
33
36
|
function Range({ range, selectedTool, relativeFormat }) {
|
|
34
|
-
const { id, integration, signals, from, to, diaIDs: rangeDiaIDs } = range;
|
|
37
|
+
const { id, integration, signals, from, to, diaIDs: rangeDiaIDs, assignment, } = range;
|
|
35
38
|
const assignmentData = useAssignmentData();
|
|
36
39
|
const assignmentRange = useAssignment(id);
|
|
37
40
|
const highlightRange = useHighlight([assignmentRange.id].concat(assignmentRange.assigned?.x || []).concat(filterForIDsWithAssignment(assignmentData, signals.map((_signal) => _signal.id))), { type: HighlightEventSource.RANGE, extra: { id } });
|
|
@@ -83,10 +86,49 @@ function Range({ range, selectedTool, relativeFormat }) {
|
|
|
83
86
|
const isHighlighted = isBlockedByEditing || highlightRange.isActive || assignmentRange.isActive;
|
|
84
87
|
const isAssigned = isRangeAssigned(range);
|
|
85
88
|
const isResizingActive = useResizerStatus('rangePicking');
|
|
86
|
-
const
|
|
87
|
-
|
|
89
|
+
const { setData: addNewAssignmentLabel } = useShareData();
|
|
90
|
+
const isAssignmentActive = !!(assignmentRange.isActive || rangeDiaIDs);
|
|
91
|
+
function removeAssignemntlabel() {
|
|
92
|
+
dispatch({
|
|
93
|
+
type: 'CHANGE_RANGE_ASSIGNMENT_LABEL',
|
|
94
|
+
payload: {
|
|
95
|
+
value: '',
|
|
96
|
+
rangeID: id,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const actionsButtons = [
|
|
101
|
+
{
|
|
102
|
+
icon: _jsx(LuLink, {}),
|
|
103
|
+
onClick: assignHandler,
|
|
104
|
+
intent: 'success',
|
|
105
|
+
title: 'Assign range',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
icon: _jsx(LuUnlink, {}),
|
|
109
|
+
onClick: () => unAssignHandler(),
|
|
110
|
+
intent: 'danger',
|
|
111
|
+
title: 'Unassign range',
|
|
112
|
+
visible: isAssignmentActive,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
icon: _jsx(PiTextTBold, {}),
|
|
116
|
+
onClick: () => addNewAssignmentLabel(range.id),
|
|
117
|
+
intent: 'success',
|
|
118
|
+
title: 'Add assignment label',
|
|
119
|
+
visible: !assignment,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
icon: _jsx(PiTextTSlashBold, {}),
|
|
123
|
+
onClick: removeAssignemntlabel,
|
|
124
|
+
intent: 'danger',
|
|
125
|
+
title: 'Remove assignment label',
|
|
126
|
+
visible: !!assignment,
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
return (_jsx("g", { "data-testid": "range", style: { outline: 'none' }, onMouseEnter: mouseEnterHandler, onMouseLeave: mouseLeaveHandler, ...(!assignmentRange.isActive && { css: style }), children: _jsx(ActionsButtonsPopover, { targetTagName: "g", ...(assignmentRange.isActive && { isOpen: true }), buttons: actionsButtons, children: _jsx(ResizerWithScale, { from: from, to: to, onEnd: handleOnStopResizing, disabled: !isResizingActive, children: ({ x1, x2 }, isActive) => {
|
|
88
130
|
const width = x2 - x1;
|
|
89
|
-
return (_jsxs("g", { children: [isAssigned && !isHighlighted && !isActive && (_jsx("rect", { width: width, height: "10px", fill: "#ffd700", opacity: "0.35", "data-no-export": "true" })), _jsx("rect", { width: width, height: "100%", fill: isHighlighted || isActive ? '#ff6f0057' : 'transparent', "data-no-export": "true" }), showIntegralsValues && (_jsx(IntegralIndicator, { value: integration, format: relativeFormat, width: width, opacity: isNotSignal ? 0.5 : 1 }))] }));
|
|
90
|
-
} })
|
|
131
|
+
return (_jsxs("g", { children: [isAssigned && !isHighlighted && !isActive && (_jsx("rect", { width: width, height: "10px", fill: "#ffd700", opacity: "0.35", "data-no-export": "true" })), _jsx("rect", { width: width, height: "100%", fill: isHighlighted || isActive ? '#ff6f0057' : 'transparent', "data-no-export": "true" }), _jsx(AssignmentLabel, { range: range, width: width }), _jsx(Atoms, { range: range, x: width / 2 }), showIntegralsValues && (_jsx(IntegralIndicator, { value: integration, format: relativeFormat, width: width, opacity: isNotSignal ? 0.5 : 1 }))] }));
|
|
132
|
+
} }) }) }, id));
|
|
91
133
|
}
|
|
92
134
|
export default Range;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { memo } from 'react';
|
|
3
3
|
import { useChartData } from '../../context/ChartContext';
|
|
4
|
+
import { ShareDataProvider } from '../../context/ShareDataContext';
|
|
4
5
|
import { useActiveSpectrumRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
|
|
5
6
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
6
7
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
7
8
|
import Range from './Range';
|
|
8
9
|
function RangesInner({ ranges, displayerKey, selectedTool, showMultiplicityTrees, relativeFormat, }) {
|
|
9
|
-
return (_jsx("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, children: ranges?.values?.map((range) => (_jsx(Range, { range: range, selectedTool: selectedTool, showMultiplicityTrees: showMultiplicityTrees, relativeFormat: relativeFormat }, range.id))) }));
|
|
10
|
+
return (_jsx(ShareDataProvider, { children: _jsx("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, children: ranges?.values?.map((range) => (_jsx(Range, { range: range, selectedTool: selectedTool, showMultiplicityTrees: showMultiplicityTrees, relativeFormat: relativeFormat }, range.id))) }) }));
|
|
10
11
|
}
|
|
11
12
|
const MemoizedRanges = memo(RangesInner);
|
|
12
13
|
const emptyData = { ranges: {}, info: {}, display: {} };
|
|
@@ -5,14 +5,21 @@ import { useActiveSpectrumRangesViewState } from '../../hooks/useActiveSpectrumR
|
|
|
5
5
|
import useIntegralPath from '../../hooks/useIntegralPath';
|
|
6
6
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
7
7
|
function Integral(props) {
|
|
8
|
-
const { x, y, max } = props;
|
|
8
|
+
const { x, y, max, from, to } = props;
|
|
9
9
|
const { integralsScaleRatio } = useActiveSpectrumRangesViewState();
|
|
10
|
-
const path = useIntegralPath({
|
|
10
|
+
const path = useIntegralPath({
|
|
11
|
+
x,
|
|
12
|
+
y,
|
|
13
|
+
max,
|
|
14
|
+
scaleRatio: integralsScaleRatio,
|
|
15
|
+
from,
|
|
16
|
+
to,
|
|
17
|
+
});
|
|
11
18
|
return (_jsx("path", { className: "line", stroke: "black", strokeWidth: "1", fill: "none", d: path }));
|
|
12
19
|
}
|
|
13
20
|
const emptyData = { ranges: {}, info: {}, display: {} };
|
|
14
21
|
function RangesIntegrals() {
|
|
15
|
-
const { displayerKey } = useChartData();
|
|
22
|
+
const { displayerKey, xDomain: [from, to], } = useChartData();
|
|
16
23
|
const spectrum = useSpectrum(emptyData);
|
|
17
24
|
const integrals = useIntegrals();
|
|
18
25
|
if (!spectrum.ranges?.values ||
|
|
@@ -22,7 +29,7 @@ function RangesIntegrals() {
|
|
|
22
29
|
return null;
|
|
23
30
|
}
|
|
24
31
|
return (_jsx("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, children: integrals.values.map((integral) => {
|
|
25
|
-
return _jsx(Integral, { ...integral, max: integrals.max }, integral.id);
|
|
32
|
+
return (_jsx(Integral, { ...integral, max: integrals.max, from, to }, integral.id));
|
|
26
33
|
}) }));
|
|
27
34
|
}
|
|
28
35
|
function useIntegrals() {
|
|
@@ -23,6 +23,7 @@ interface IntegralYScaleOptions {
|
|
|
23
23
|
scaleRatio: number;
|
|
24
24
|
}
|
|
25
25
|
declare function getIntegralYScale(options: IntegralYScaleOptions): import("d3-scale").ScaleLinear<number, number, never>;
|
|
26
|
+
declare function getYScaleWithRation(options: IntegralYScaleOptions): import("d3-scale").ScaleLinear<number, number, never>;
|
|
26
27
|
declare function reScaleY(scale: number, { domain, height, margin }: {
|
|
27
28
|
domain: any;
|
|
28
29
|
height: any;
|
|
@@ -30,4 +31,4 @@ declare function reScaleY(scale: number, { domain, height, margin }: {
|
|
|
30
31
|
}): number[];
|
|
31
32
|
declare function useScaleX(): (spectrumId?: null) => import("d3-scale").ScaleLinear<number, number, never>;
|
|
32
33
|
declare function useScaleY(): (spectrumId?: null) => import("d3-scale").ScaleLinear<number, number, never>;
|
|
33
|
-
export { useScaleX, useScaleY, getXScale, getYScale, getIntegralYScale, reScaleY, };
|
|
34
|
+
export { useScaleX, useScaleY, getXScale, getYScale, getIntegralYScale, reScaleY, getYScaleWithRation, };
|
|
@@ -34,6 +34,11 @@ function getIntegralYScale(options) {
|
|
|
34
34
|
const [min, max] = yDomain;
|
|
35
35
|
return scaleLinear([min * scaleRatio, max * scaleRatio], [height * 0.3, margin.top + height * 0.1]);
|
|
36
36
|
}
|
|
37
|
+
function getYScaleWithRation(options) {
|
|
38
|
+
const { height, margin, yDomain, scaleRatio } = options;
|
|
39
|
+
const [min, max] = yDomain;
|
|
40
|
+
return scaleLinear([min * scaleRatio, max * scaleRatio], [height - margin.bottom - SPECTRA_BOTTOM_MARGIN, margin.top]);
|
|
41
|
+
}
|
|
37
42
|
function reScaleY(scale, { domain, height, margin }) {
|
|
38
43
|
const _scale = scaleLinear(domain, [height - margin.bottom, margin.top]);
|
|
39
44
|
const t = zoomIdentity
|
|
@@ -51,4 +56,4 @@ function useScaleY() {
|
|
|
51
56
|
const verticalAlign = useVerticalAlign();
|
|
52
57
|
return useCallback((spectrumId = null) => getYScale({ margin, height, verticalAlign, yDomain, yDomains }, spectrumId), [margin, height, verticalAlign, yDomain, yDomains]);
|
|
53
58
|
}
|
|
54
|
-
export { useScaleX, useScaleY, getXScale, getYScale, getIntegralYScale, reScaleY, };
|
|
59
|
+
export { useScaleX, useScaleY, getXScale, getYScale, getIntegralYScale, reScaleY, getYScaleWithRation, };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @jsxImportSource @emotion/react */
|
|
2
|
+
import { PopoverProps } from '@blueprintjs/core';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
type InputType = 'number' | 'text';
|
|
5
|
+
interface FieldEditionsProps {
|
|
6
|
+
value: number | string;
|
|
7
|
+
inputType?: InputType;
|
|
8
|
+
onChange: (value: any) => void;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
PopoverProps?: PopoverProps;
|
|
11
|
+
}
|
|
12
|
+
export declare function FieldEdition(props: FieldEditionsProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { Popover } from '@blueprintjs/core';
|
|
4
|
+
import { css } from '@emotion/react';
|
|
5
|
+
import { Formik } from 'formik';
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
import * as Yup from 'yup';
|
|
8
|
+
import FormikInput from '../elements/formik/FormikInput';
|
|
9
|
+
const InputDimension = { height: 28, width: 100 };
|
|
10
|
+
const validationSchema = (inputType) => Yup.object({
|
|
11
|
+
value: (inputType === 'number' ? Yup.number() : Yup.string()).required(),
|
|
12
|
+
});
|
|
13
|
+
function stopPropagation(e) {
|
|
14
|
+
e.stopPropagation();
|
|
15
|
+
}
|
|
16
|
+
function keyDownCheck(event) {
|
|
17
|
+
if (event.key === 'Enter') {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
else if (event.key === 'Escape') {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function FieldEdition(props) {
|
|
25
|
+
const { value, inputType = 'text', onChange, children, PopoverProps } = props;
|
|
26
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
27
|
+
function handleOnSubmit({ value: newValue }) {
|
|
28
|
+
onChange(newValue);
|
|
29
|
+
setIsOpen(false);
|
|
30
|
+
}
|
|
31
|
+
return (_jsx(Popover, { css: css `
|
|
32
|
+
.field-edition-popover {
|
|
33
|
+
border-radius: 5px;
|
|
34
|
+
}
|
|
35
|
+
`, popoverClassName: "field-edition-popover", isOpen: isOpen, onClose: () => setIsOpen(false), onInteraction: () => setIsOpen(true), content: _jsx(Formik, { initialValues: { value }, onSubmit: handleOnSubmit, validationSchema: validationSchema(inputType), children: ({ submitForm }) => (_jsx(FormikInput, { type: inputType, style: {
|
|
36
|
+
input: {
|
|
37
|
+
height: `${InputDimension.height}px`,
|
|
38
|
+
padding: '5px',
|
|
39
|
+
outline: 'none',
|
|
40
|
+
},
|
|
41
|
+
}, name: "value", autoSelect: true, onKeyDown: (e) => keyDownCheck(e) && submitForm(), onClick: stopPropagation, onMouseDown: stopPropagation })) }), ...PopoverProps, children: children }));
|
|
42
|
+
}
|
|
@@ -3,18 +3,20 @@ import { memo } from 'react';
|
|
|
3
3
|
import SpectrumInfoBlock from '../1d-2d/components/SpectrumInfoBlock';
|
|
4
4
|
import { useChartData } from '../context/ChartContext';
|
|
5
5
|
import { usePreferences } from '../context/PreferencesContext';
|
|
6
|
+
import { ShareDataProvider } from '../context/ShareDataContext';
|
|
6
7
|
import XAxis from './XAxis';
|
|
7
8
|
import YAxis from './YAxis';
|
|
8
9
|
import { FidContainer } from './fid/FidContainer';
|
|
9
10
|
import { FTContainer } from './ft/FTContainer';
|
|
10
11
|
import IndicationLines from './zones/IndicationLines';
|
|
11
12
|
import Zones from './zones/Zones';
|
|
12
|
-
|
|
13
|
+
import ZonesAssignmentsLabels from './zones/ZonesAssignmentsLabels';
|
|
14
|
+
function Chart2DInner({ spectra, width, height, margin, displayerKey, spectraRendering, }) {
|
|
13
15
|
return (_jsxs("svg", { id: "nmrSVG", viewBox: `0 0 ${width} ${height}`, width: width, height: height, fontFamily: "Arial, Helvetica, sans-serif", shapeRendering: spectraRendering, style: {
|
|
14
16
|
position: 'absolute',
|
|
15
|
-
}, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-chart-2d`, children: _jsx("rect", { width: width - margin.left - margin.right, height: height - margin.top - margin.bottom, x: margin.left, y: margin.top }) }) }), _jsx("rect", { width: width - margin.left - margin.right, height: height - margin.top - margin.bottom, x: margin.left, y: margin.top, stroke: "black", strokeWidth: "1", fill: "transparent" }), _jsx(FTContainer, { spectra: spectra }), _jsx(FidContainer, {}), _jsx(Zones, {}), _jsx(IndicationLines, { axis: "X", show: true }), _jsx(IndicationLines, { axis: "Y", show: true }), _jsx(SpectrumInfoBlock, {}), _jsxs("g", { className: "container", style: { pointerEvents: 'none' }, children: [_jsx(XAxis, {}), _jsx(YAxis, {})] })] }));
|
|
17
|
+
}, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-chart-2d`, children: _jsx("rect", { width: width - margin.left - margin.right, height: height - margin.top - margin.bottom, x: margin.left, y: margin.top }) }) }), _jsx("rect", { width: width - margin.left - margin.right, height: height - margin.top - margin.bottom, x: margin.left, y: margin.top, stroke: "black", strokeWidth: "1", fill: "transparent" }), _jsx(FTContainer, { spectra: spectra }), _jsx(FidContainer, {}), _jsxs(ShareDataProvider, { children: [_jsx(Zones, {}), _jsx(ZonesAssignmentsLabels, {})] }), _jsx(IndicationLines, { axis: "X", show: true }), _jsx(IndicationLines, { axis: "Y", show: true }), _jsx(SpectrumInfoBlock, {}), _jsxs("g", { className: "container", style: { pointerEvents: 'none' }, children: [_jsx(XAxis, {}), _jsx(YAxis, {})] })] }));
|
|
16
18
|
}
|
|
17
|
-
const MemoizedChart2D = memo(
|
|
19
|
+
const MemoizedChart2D = memo(Chart2DInner);
|
|
18
20
|
export default function Chart2D({ spectra }) {
|
|
19
21
|
const { width, height, margin, displayerKey } = useChartData();
|
|
20
22
|
const { current: { general: { spectraRendering }, }, } = usePreferences();
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
|
+
import styled from '@emotion/styled';
|
|
4
5
|
import { useState, useEffect } from 'react';
|
|
6
|
+
import { PiTextTBold } from 'react-icons/pi';
|
|
5
7
|
import { checkZoneKind } from '../../../data/utilities/ZoneUtilities';
|
|
6
8
|
import { useAssignment } from '../../assignment/AssignmentsContext';
|
|
9
|
+
import { useShareData } from '../../context/ShareDataContext';
|
|
10
|
+
import { SVGButton } from '../../elements/SVGButton';
|
|
7
11
|
import { HighlightEventSource, useHighlight } from '../../highlight';
|
|
8
12
|
import { useActiveSpectrumZonesViewState } from '../../hooks/useActiveSpectrumZonesViewState';
|
|
9
13
|
import { useScale2DX, useScale2DY } from '../utilities/scale';
|
|
@@ -37,8 +41,20 @@ const stylesHighlighted = css `
|
|
|
37
41
|
cursor: pointer;
|
|
38
42
|
}
|
|
39
43
|
`;
|
|
44
|
+
const GroupContainer = styled.g `
|
|
45
|
+
.target {
|
|
46
|
+
visibility: hidden;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&:hover {
|
|
50
|
+
.target {
|
|
51
|
+
visibility: visible;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
40
55
|
function Zone({ zoneData }) {
|
|
41
|
-
const { x, y, id, signals } = zoneData;
|
|
56
|
+
const { x, y, id, signals, assignment } = zoneData;
|
|
57
|
+
const { setData } = useShareData();
|
|
42
58
|
const assignmentZone = useAssignment(id);
|
|
43
59
|
const { showZones } = useActiveSpectrumZonesViewState();
|
|
44
60
|
const highlightZone = useHighlight([assignmentZone.id], {
|
|
@@ -61,6 +77,6 @@ function Zone({ zoneData }) {
|
|
|
61
77
|
}, onMouseLeave: () => {
|
|
62
78
|
assignmentZone.hide();
|
|
63
79
|
highlightZone.hide();
|
|
64
|
-
}, children: [showZones && (
|
|
80
|
+
}, children: [showZones && (_jsxs(GroupContainer, { transform: `translate(${scaleX(x2)},${scaleY(y1)})`, children: [_jsx("g", { "data-no-export": "true", transform: "translate(-16 -16)", className: "target", children: !assignment && (_jsx(SVGButton, { renderIcon: (props) => _jsx(PiTextTBold, { ...props }), backgroundColor: "green", title: "Add assignment label", style: { cursor: 'hand' }, onClick: () => setData({ id }) })) }), _jsx("rect", { x: "0", width: scaleX(x1) - scaleX(x2), height: scaleY(y2) - scaleY(y1), className: "integral-area", fill: "#0000000f", stroke: reduceOpacity ? '#343a40' : 'darkgreen', strokeWidth: reduceOpacity ? '0' : '1' })] })), signals.map((_signal, i) => (_jsx(Signal, { signal: _signal }, String(id + i))))] }, id));
|
|
65
81
|
}
|
|
66
82
|
export default Zone;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Zone } from 'nmr-processing';
|
|
2
|
+
interface AssignmentLabelProps {
|
|
3
|
+
zone: Zone;
|
|
4
|
+
}
|
|
5
|
+
export declare function AssignmentLabel(props: AssignmentLabelProps): import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
export default function ZonesAssignmentsLabels(): import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
4
|
+
import { PiTextTSlash } from 'react-icons/pi';
|
|
5
|
+
import { FieldEdition } from '../../1d-2d/FieldEdition';
|
|
6
|
+
import { useChartData } from '../../context/ChartContext';
|
|
7
|
+
import { useDispatch } from '../../context/DispatchContext';
|
|
8
|
+
import { useGlobal } from '../../context/GlobalContext';
|
|
9
|
+
import { useShareData } from '../../context/ShareDataContext';
|
|
10
|
+
import { SVGButton } from '../../elements/SVGButton';
|
|
11
|
+
import { SVGGroup } from '../../elements/SVGGroup';
|
|
12
|
+
import useDraggable from '../../elements/draggable/useDraggable';
|
|
13
|
+
import { useHighlight } from '../../highlight';
|
|
14
|
+
import { useActiveSpectrumZonesViewState } from '../../hooks/useActiveSpectrumZonesViewState';
|
|
15
|
+
import useSpectrum from '../../hooks/useSpectrum';
|
|
16
|
+
import { useScale2DX, useScale2DY } from '../utilities/scale';
|
|
17
|
+
const distance = 30;
|
|
18
|
+
const iconSize = 16;
|
|
19
|
+
const LabelBoxPadding = { left: 35, right: 0, top: 15, bottom: 15 };
|
|
20
|
+
function getDistance(x1, y1, x2, y2) {
|
|
21
|
+
const deltaX = x2 - x1;
|
|
22
|
+
const deltaY = y2 - y1;
|
|
23
|
+
return Math.hypot(deltaX, deltaY);
|
|
24
|
+
}
|
|
25
|
+
function radiansToDegrees(radians) {
|
|
26
|
+
return radians * (180 / Math.PI);
|
|
27
|
+
}
|
|
28
|
+
function getAngleFromSides(a, b, c) {
|
|
29
|
+
const radians = Math.acos((b ** 2 + c ** 2 - a ** 2) / (2 * b * c));
|
|
30
|
+
return radiansToDegrees(radians);
|
|
31
|
+
}
|
|
32
|
+
function findBestLink(sourcePoints, targetPoints) {
|
|
33
|
+
const result = [];
|
|
34
|
+
for (const sourcePoint of sourcePoints) {
|
|
35
|
+
const { a, b } = sourcePoint;
|
|
36
|
+
for (const targetPoint of targetPoints) {
|
|
37
|
+
const { x, y } = targetPoint;
|
|
38
|
+
const aLength = getDistance(a.x, a.y, x, y);
|
|
39
|
+
const bLength = getDistance(b.x, b.y, x, y);
|
|
40
|
+
const deltaLength = getDistance(a.x, a.y, b.x, b.y);
|
|
41
|
+
const distance = Math.min(aLength, bLength);
|
|
42
|
+
const angle = Number(getAngleFromSides(deltaLength, aLength, bLength).toFixed(1));
|
|
43
|
+
result.push({ distance, angle, targetPoint, sourcePoint });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
result.sort((a, b) => {
|
|
47
|
+
if (a.angle !== b.angle) {
|
|
48
|
+
return b.angle - a.angle;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return a.distance - b.distance;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return result[0];
|
|
55
|
+
}
|
|
56
|
+
function useLinkPath(currentPosition, targetBoundary, sourceElementBoundary, options = {}) {
|
|
57
|
+
const { sideLength = 6, shift = 5 } = options;
|
|
58
|
+
const { x1, x2, y1, y2 } = targetBoundary;
|
|
59
|
+
const { x, y } = currentPosition;
|
|
60
|
+
const scaleX = useScale2DX();
|
|
61
|
+
const scaleY = useScale2DY();
|
|
62
|
+
const { width, height } = sourceElementBoundary;
|
|
63
|
+
const centerX = width / 2;
|
|
64
|
+
const centerY = height / 2;
|
|
65
|
+
const leftX = x - centerX - shift;
|
|
66
|
+
const rightX = x + centerX + shift;
|
|
67
|
+
const topY = y - height;
|
|
68
|
+
const bottomY = y + shift;
|
|
69
|
+
const targetWidth = scaleX(x2) - scaleX(x1);
|
|
70
|
+
const targetHeight = scaleY(y2) - scaleY(y1);
|
|
71
|
+
const targetXCenter = scaleX(x1) + targetWidth / 2;
|
|
72
|
+
const targetYCenter = scaleY(y1) + targetHeight / 2;
|
|
73
|
+
const sourcePoints = [
|
|
74
|
+
{
|
|
75
|
+
a: { x, y: bottomY },
|
|
76
|
+
b: { x: x + sideLength, y: bottomY },
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
a: { x, y: topY },
|
|
80
|
+
b: { x: x + sideLength, y: topY },
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
a: { x: leftX, y: y - centerY - sideLength / 2 },
|
|
84
|
+
b: { x: leftX, y: y - centerY + sideLength / 2 },
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
a: { x: rightX, y: y - centerY - sideLength / 2 },
|
|
88
|
+
b: { x: rightX, y: y - centerY + sideLength / 2 },
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
/**
|
|
92
|
+
* Zone coordination
|
|
93
|
+
* xMid= x2-x1/2;
|
|
94
|
+
* yMid= y2-y1/2;
|
|
95
|
+
* (x1,y1) ---------- (xMid,y1) ---------- (x2,y1)
|
|
96
|
+
* | |
|
|
97
|
+
* | |
|
|
98
|
+
* (x1,yMid) (x2,yMid)
|
|
99
|
+
* | |
|
|
100
|
+
* | |
|
|
101
|
+
* (x1,y2) ---------- (xMid,y2) ---------- (x2,y2)
|
|
102
|
+
*
|
|
103
|
+
*/
|
|
104
|
+
const targetPoints = [
|
|
105
|
+
{
|
|
106
|
+
//Left Top
|
|
107
|
+
x: scaleX(x1),
|
|
108
|
+
y: scaleY(y1),
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
//Center Top
|
|
112
|
+
x: targetXCenter,
|
|
113
|
+
y: scaleY(y1),
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
//Right Top
|
|
117
|
+
x: scaleX(x2),
|
|
118
|
+
y: scaleY(y1),
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
//Right Center
|
|
122
|
+
x: scaleX(x2),
|
|
123
|
+
y: targetYCenter,
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
//Right Bottom
|
|
127
|
+
x: scaleX(x2),
|
|
128
|
+
y: scaleY(y2),
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
//Center Bottom
|
|
132
|
+
x: targetXCenter,
|
|
133
|
+
y: scaleY(y2),
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
//Left Bottom
|
|
137
|
+
x: scaleX(x1),
|
|
138
|
+
y: scaleY(y2),
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
//Left Center
|
|
142
|
+
x: scaleX(x1),
|
|
143
|
+
y: targetYCenter,
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
const link = findBestLink(sourcePoints, targetPoints);
|
|
147
|
+
return `${link.sourcePoint.a.x},${link.sourcePoint.a.y} ${link.sourcePoint.b.x},${link.sourcePoint.b.y} ${link.targetPoint.x},${link.targetPoint.y}`;
|
|
148
|
+
}
|
|
149
|
+
const GroupContainer = styled.g(({ isMoveActive }) => !isMoveActive
|
|
150
|
+
? `
|
|
151
|
+
|
|
152
|
+
pointer-events: bounding-box;
|
|
153
|
+
|
|
154
|
+
.target {
|
|
155
|
+
visibility: hidden;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
&:hover {
|
|
159
|
+
.target {
|
|
160
|
+
visibility: visible;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
`
|
|
164
|
+
: ``);
|
|
165
|
+
export function AssignmentLabel(props) {
|
|
166
|
+
const { zone } = props;
|
|
167
|
+
const { id, x, y, assignment } = zone;
|
|
168
|
+
const dispatch = useDispatch();
|
|
169
|
+
const { isActive } = useHighlight([zone.id]);
|
|
170
|
+
const { assignmentsLabelsCoordinates } = useActiveSpectrumZonesViewState();
|
|
171
|
+
const scaleX = useScale2DX();
|
|
172
|
+
const scaleY = useScale2DY();
|
|
173
|
+
const { viewerRef } = useGlobal();
|
|
174
|
+
const textRef = useRef(null);
|
|
175
|
+
const [labelBoundary, setLabelBoundary] = useState({
|
|
176
|
+
width: 0,
|
|
177
|
+
height: 0,
|
|
178
|
+
});
|
|
179
|
+
const [isMoveActive, setIsMoveActive] = useState(false);
|
|
180
|
+
const { data: newAssignmentLabelState, setData: updateNewAssignmentLabelState, } = useShareData();
|
|
181
|
+
function dismissNewLabel() {
|
|
182
|
+
if (newAssignmentLabelState) {
|
|
183
|
+
updateNewAssignmentLabelState(null);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
let coordinate = {
|
|
187
|
+
x: scaleX(x.to),
|
|
188
|
+
y: scaleY(y.from) - distance,
|
|
189
|
+
};
|
|
190
|
+
if (assignmentsLabelsCoordinates?.[id]) {
|
|
191
|
+
coordinate = {
|
|
192
|
+
x: scaleX(assignmentsLabelsCoordinates[id].x),
|
|
193
|
+
y: scaleY(assignmentsLabelsCoordinates[id].y),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
const [currentPosition, setCurrentPosition] = useState(coordinate);
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
setCurrentPosition({ x: coordinate.x, y: coordinate.y });
|
|
199
|
+
}, [coordinate.x, coordinate.y]);
|
|
200
|
+
useLayoutEffect(() => {
|
|
201
|
+
if (textRef.current) {
|
|
202
|
+
const { width, height } = textRef.current.getBBox();
|
|
203
|
+
setLabelBoundary({ width, height });
|
|
204
|
+
}
|
|
205
|
+
}, [assignment]);
|
|
206
|
+
const { onPointerDown } = useDraggable({
|
|
207
|
+
position: coordinate,
|
|
208
|
+
onChange: (dragEvent) => {
|
|
209
|
+
const { action, position } = dragEvent;
|
|
210
|
+
const boundary = textRef.current?.getBBox();
|
|
211
|
+
if (!boundary)
|
|
212
|
+
return;
|
|
213
|
+
const centerX = width / 2 + LabelBoxPadding.left;
|
|
214
|
+
const centerY = height + iconSize;
|
|
215
|
+
switch (action) {
|
|
216
|
+
case 'start': {
|
|
217
|
+
setCurrentPosition({ x: position.x, y: position.y });
|
|
218
|
+
setIsMoveActive(true);
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
case 'move': {
|
|
222
|
+
setCurrentPosition({
|
|
223
|
+
x: position.x + centerX,
|
|
224
|
+
y: position.y + centerY,
|
|
225
|
+
});
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
case 'end':
|
|
229
|
+
dispatch({
|
|
230
|
+
type: 'SET_ZONE_ASSIGNMENT_LABEL_COORDINATION',
|
|
231
|
+
payload: {
|
|
232
|
+
zoneID: zone.id,
|
|
233
|
+
coordination: {
|
|
234
|
+
x: scaleX.invert(position.x + centerX),
|
|
235
|
+
y: scaleY.invert(position.y + centerY),
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
setIsMoveActive(false);
|
|
240
|
+
break;
|
|
241
|
+
default:
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
parentElement: viewerRef,
|
|
246
|
+
});
|
|
247
|
+
const path = useLinkPath(currentPosition, { x1: x.to, x2: x.from, y1: y.from, y2: y.to }, labelBoundary);
|
|
248
|
+
if (!assignment && newAssignmentLabelState?.id !== id) {
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
function handleChange(value) {
|
|
252
|
+
dismissNewLabel();
|
|
253
|
+
dispatch({
|
|
254
|
+
type: 'CHANGE_ZONE_ASSIGNMENT_LABEL',
|
|
255
|
+
payload: {
|
|
256
|
+
value,
|
|
257
|
+
zoneID: id,
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
const { width, height } = labelBoundary;
|
|
262
|
+
return (_jsxs(GroupContainer, { isMoveActive: isMoveActive, children: [_jsx("polygon", { points: path, fill: isActive ? '#ff6f0091' : 'black' }), _jsxs("g", { style: {
|
|
263
|
+
transform: `translate(${currentPosition.x}px,${currentPosition.y}px)`,
|
|
264
|
+
}, children: [_jsx("rect", { "data-no-export": "true", fill: "transparent", x: -(width / 2 + LabelBoxPadding.left), width: width + LabelBoxPadding.left + LabelBoxPadding.right, height: height + LabelBoxPadding.top + LabelBoxPadding.bottom, y: -(height + LabelBoxPadding.top) }), _jsx(FieldEdition, { onChange: handleChange, inputType: "text", value: assignment || '', PopoverProps: {
|
|
265
|
+
position: 'top',
|
|
266
|
+
targetTagName: 'g',
|
|
267
|
+
...(newAssignmentLabelState?.id === id
|
|
268
|
+
? { isOpen: true, onClose: () => dismissNewLabel() }
|
|
269
|
+
: {}),
|
|
270
|
+
}, children: _jsx("text", { fontWeight: isActive ? 'bold' : 'normal', ref: textRef, textAnchor: "middle", fill: "black", style: { cursor: 'hand' }, children: assignment }) }), _jsxs(SVGGroup, { space: 2, "data-no-export": "true", transform: `translate(-${width / 2 + iconSize * 2 + 2} -${height + iconSize})`, className: "target", children: [_jsx(SVGButton, { title: "Move label", size: iconSize, icon: "move", onPointerDown: onPointerDown, style: { cursor: 'move' } }), _jsx(SVGButton, { size: iconSize, title: "Remove label", renderIcon: (props) => _jsx(PiTextTSlash, { ...props }), backgroundColor: "red", style: { cursor: 'hand' }, onClick: () => handleChange('') })] })] })] }));
|
|
271
|
+
}
|
|
272
|
+
function ZonesAssignmentsLabelsInner({ zones, displayerKey }) {
|
|
273
|
+
return (_jsx("g", { clipPath: `url(#${displayerKey}clip-chart-2d)`, className: "2d-zones-assignments-labels", children: zones.values.map((zone) => (_jsx(AssignmentLabel, { zone: zone }, zone.id))) }));
|
|
274
|
+
}
|
|
275
|
+
const emptyData = { zones: {}, display: {} };
|
|
276
|
+
export default function ZonesAssignmentsLabels() {
|
|
277
|
+
const { displayerKey } = useChartData();
|
|
278
|
+
const { zones, display } = useSpectrum(emptyData);
|
|
279
|
+
const { showAssignmentsLabels } = useActiveSpectrumZonesViewState();
|
|
280
|
+
const { data: NewAssignmentLabelState } = useShareData();
|
|
281
|
+
if ((!display.isVisible || !showAssignmentsLabels) &&
|
|
282
|
+
!NewAssignmentLabelState) {
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
return _jsx(ZonesAssignmentsLabelsInner, { zones, displayerKey });
|
|
286
|
+
}
|
|
@@ -19,7 +19,7 @@ function KeysListenerTracker(props) {
|
|
|
19
19
|
const { mainDivRef } = props;
|
|
20
20
|
const { keysPreferences, displayerMode, data, view: { spectra: { activeTab }, }, } = useChartData();
|
|
21
21
|
const dispatch = useDispatch();
|
|
22
|
-
const { dispatch: dispatchPreferences } = usePreferences();
|
|
22
|
+
const { dispatch: dispatchPreferences, current: { nuclei }, } = usePreferences();
|
|
23
23
|
const toaster = useToaster();
|
|
24
24
|
const modal = useModal();
|
|
25
25
|
const openLoader = useLoader();
|
|
@@ -394,6 +394,18 @@ function KeysListenerTracker(props) {
|
|
|
394
394
|
default:
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
|
+
if (e.shiftKey) {
|
|
398
|
+
switch (e.key) {
|
|
399
|
+
case 'F': {
|
|
400
|
+
dispatch({
|
|
401
|
+
type: 'SET_AXIS_DOMAIN',
|
|
402
|
+
payload: { nucleiPreferences: nuclei },
|
|
403
|
+
});
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
default:
|
|
407
|
+
}
|
|
408
|
+
}
|
|
397
409
|
if (e.shiftKey && (e.metaKey || e.ctrlKey)) {
|
|
398
410
|
switch (e.key) {
|
|
399
411
|
case 's':
|
|
@@ -417,6 +429,7 @@ function KeysListenerTracker(props) {
|
|
|
417
429
|
handleChangeOption,
|
|
418
430
|
handleFullZoomOut,
|
|
419
431
|
isToolVisible,
|
|
432
|
+
nuclei,
|
|
420
433
|
openLoader,
|
|
421
434
|
openSaveAsDialog,
|
|
422
435
|
saveAsJSONHandler,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface PrepareExportContextState {
|
|
3
|
+
registerComponent: (componentId: any) => void;
|
|
4
|
+
unRegisterComponent: (componentId: any) => void;
|
|
5
|
+
notifyComponentLoaded: (componentId: any) => void;
|
|
6
|
+
prepareExportStart: () => void;
|
|
7
|
+
waitForAllComponentsRendered: () => Promise<void>;
|
|
8
|
+
prepareExportEnd: () => void;
|
|
9
|
+
isExporting: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface PrepareExportProviderProps {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
timeout?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function usePrepareExport(): PrepareExportContextState;
|
|
16
|
+
export declare function useRegisterExportComponents(componentId: string): void;
|
|
17
|
+
export declare function useNotifyComponentLoaded(componentId: string): void;
|
|
18
|
+
export declare function PrepareExportProvider(props: PrepareExportProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function withExportRegister<P extends object>(Component: React.ComponentType<P>, componentId: string): (props: P) => import("react/jsx-runtime").JSX.Element | null;
|
|
20
|
+
export declare function withExport<P extends object>(Component: React.ComponentType<P>, componentId: string): (props: P) => import("react/jsx-runtime").JSX.Element | null;
|
|
21
|
+
export {};
|