nmrium 0.63.1 → 0.64.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/BrushTracker1D.d.ts.map +1 -1
- package/lib/component/1d/BrushTracker1D.js +8 -1
- package/lib/component/1d/BrushTracker1D.js.map +1 -1
- package/lib/component/1d/PredictionErrorsNotations.d.ts +2 -0
- package/lib/component/1d/PredictionErrorsNotations.d.ts.map +1 -0
- package/lib/component/1d/PredictionErrorsNotations.js +112 -0
- package/lib/component/1d/PredictionErrorsNotations.js.map +1 -0
- package/lib/component/1d/SVGContent1D.d.ts.map +1 -1
- package/lib/component/1d/SVGContent1D.js +2 -1
- package/lib/component/1d/SVGContent1D.js.map +1 -1
- package/lib/component/2d/ft/Contours.d.ts.map +1 -1
- package/lib/component/2d/ft/Contours.js +3 -4
- package/lib/component/2d/ft/Contours.js.map +1 -1
- package/lib/component/2d/utilities/extractSpectrumSignals.d.ts +5 -3
- package/lib/component/2d/utilities/extractSpectrumSignals.d.ts.map +1 -1
- package/lib/component/2d/utilities/extractSpectrumSignals.js +3 -3
- package/lib/component/2d/utilities/extractSpectrumSignals.js.map +1 -1
- package/lib/component/2d/zones/SignalsGuideLines.d.ts.map +1 -1
- package/lib/component/2d/zones/SignalsGuideLines.js +74 -6
- package/lib/component/2d/zones/SignalsGuideLines.js.map +1 -1
- package/lib/component/EventsTrackers/BrushTracker.d.ts.map +1 -1
- package/lib/component/EventsTrackers/BrushTracker.js +2 -2
- package/lib/component/EventsTrackers/BrushTracker.js.map +1 -1
- package/lib/component/assignment/AssignmentProvider.d.ts.map +1 -1
- package/lib/component/assignment/AssignmentProvider.js +2 -1
- package/lib/component/assignment/AssignmentProvider.js.map +1 -1
- package/lib/component/assignment/AssignmentsContext.d.ts +5 -2
- package/lib/component/assignment/AssignmentsContext.d.ts.map +1 -1
- package/lib/component/assignment/AssignmentsContext.js +2 -1
- package/lib/component/assignment/AssignmentsContext.js.map +1 -1
- package/lib/component/elements/SVGGroup.js +1 -1
- package/lib/component/elements/SVGGroup.js.map +1 -1
- package/lib/component/elements/Sections.d.ts +1 -0
- package/lib/component/elements/Sections.d.ts.map +1 -1
- package/lib/component/elements/Sections.js +42 -7
- package/lib/component/elements/Sections.js.map +1 -1
- package/lib/component/elements/pdnd.cjs +12 -0
- package/lib/component/elements/pdnd.cjs.map +1 -0
- package/lib/component/elements/pdnd.d.cts +2 -0
- package/lib/component/elements/pdnd.d.cts.map +1 -0
- package/lib/component/hooks/useToolsFunctions.js +1 -1
- package/lib/component/hooks/useToolsFunctions.js.map +1 -1
- package/lib/component/main/InnerNMRiumContents.d.ts.map +1 -1
- package/lib/component/main/InnerNMRiumContents.js +3 -1
- package/lib/component/main/InnerNMRiumContents.js.map +1 -1
- package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.d.ts.map +1 -1
- package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.js +7 -4
- package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.js.map +1 -1
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +6 -5
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js.map +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts.map +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +3 -2
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js.map +1 -1
- package/lib/component/panels/MoleculesPanel/Utilities.d.ts.map +1 -1
- package/lib/component/panels/MoleculesPanel/Utilities.js +2 -0
- package/lib/component/panels/MoleculesPanel/Utilities.js.map +1 -1
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts.map +1 -1
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +17 -9
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js.map +1 -1
- package/lib/component/panels/Panels.d.ts +0 -4
- package/lib/component/panels/Panels.d.ts.map +1 -1
- package/lib/component/panels/Panels.js +8 -14
- package/lib/component/panels/Panels.js.map +1 -1
- package/lib/component/panels/RangesPanel/RangesHeader.d.ts.map +1 -1
- package/lib/component/panels/RangesPanel/RangesHeader.js +5 -8
- package/lib/component/panels/RangesPanel/RangesHeader.js.map +1 -1
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.d.ts.map +1 -1
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.js +4 -1
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.js.map +1 -1
- package/lib/component/panels/extra/utilities/MultiplicityUtilities.d.ts +1 -1
- package/lib/component/panels/extra/utilities/MultiplicityUtilities.d.ts.map +1 -1
- package/lib/component/panels/filtersPanel/Filters/FiltersSectionsPanel.d.ts.map +1 -1
- package/lib/component/panels/filtersPanel/Filters/FiltersSectionsPanel.js +7 -1
- package/lib/component/panels/filtersPanel/Filters/FiltersSectionsPanel.js.map +1 -1
- package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.d.ts +1 -1
- package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.d.ts.map +1 -1
- package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.js +15 -17
- package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.js.map +1 -1
- package/lib/component/panels/hooks/useTogglePanel.d.ts.map +1 -1
- package/lib/component/panels/hooks/useTogglePanel.js +4 -3
- package/lib/component/panels/hooks/useTogglePanel.js.map +1 -1
- package/lib/component/reducer/Reducer.d.ts.map +1 -1
- package/lib/component/reducer/Reducer.js +2 -0
- package/lib/component/reducer/Reducer.js.map +1 -1
- package/lib/component/reducer/actions/FiltersActions.d.ts +7 -2
- package/lib/component/reducer/actions/FiltersActions.d.ts.map +1 -1
- package/lib/component/reducer/actions/FiltersActions.js +56 -26
- package/lib/component/reducer/actions/FiltersActions.js.map +1 -1
- package/lib/component/reducer/actions/InsetActions.d.ts.map +1 -1
- package/lib/component/reducer/actions/InsetActions.js +1 -5
- package/lib/component/reducer/actions/InsetActions.js.map +1 -1
- package/lib/component/reducer/actions/RangesActions.d.ts +3 -1
- package/lib/component/reducer/actions/RangesActions.d.ts.map +1 -1
- package/lib/component/reducer/actions/RangesActions.js +7 -14
- package/lib/component/reducer/actions/RangesActions.js.map +1 -1
- package/lib/component/reducer/actions/ToolsActions.d.ts.map +1 -1
- package/lib/component/reducer/actions/ToolsActions.js +2 -2
- package/lib/component/reducer/actions/ToolsActions.js.map +1 -1
- package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +3 -2
- package/lib/component/reducer/helper/ZoomHistoryManager.d.ts.map +1 -1
- package/lib/component/reducer/helper/ZoomHistoryManager.js +17 -8
- package/lib/component/reducer/helper/ZoomHistoryManager.js.map +1 -1
- package/lib/component/reducer/preferences/actions/togglePanel.d.ts.map +1 -1
- package/lib/component/reducer/preferences/actions/togglePanel.js +11 -6
- package/lib/component/reducer/preferences/actions/togglePanel.js.map +1 -1
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -1
- package/lib/component/reducer/preferences/preferencesReducer.d.ts.map +1 -1
- package/lib/component/reducer/preferences/preferencesReducer.js.map +1 -1
- package/lib/component/toolbar/ToolBar.js +3 -2
- package/lib/component/toolbar/ToolBar.js.map +1 -1
- package/lib/component/toolbar/ToolTypes.js +1 -1
- package/lib/component/toolbar/ToolTypes.js.map +1 -1
- package/lib/component/workspaces/exercise.js +1 -1
- package/lib/component/workspaces/prediction.js +1 -1
- package/lib/component/workspaces/prediction.js.map +1 -1
- package/lib/component/workspaces/workspaceDefaultProperties.js +1 -1
- package/lib/data/PredictionManager.d.ts.map +1 -1
- package/lib/data/PredictionManager.js +1 -0
- package/lib/data/PredictionManager.js.map +1 -1
- package/lib/data/data2d/Spectrum2D/contours.d.ts.map +1 -1
- package/lib/data/data2d/Spectrum2D/contours.js +6 -4
- package/lib/data/data2d/Spectrum2D/contours.js.map +1 -1
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.d.ts.map +1 -1
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +22 -10
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js.map +1 -1
- package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts.map +1 -1
- package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts.map +1 -1
- package/lib/data/types/data1d/index.js +1 -1
- package/lib/data/types/data1d/index.js.map +1 -1
- package/lib/versionInfo.js +1 -1
- package/package.json +22 -21
- package/src/component/1d/BrushTracker1D.tsx +8 -1
- package/src/component/1d/PredictionErrorsNotations.tsx +209 -0
- package/src/component/1d/SVGContent1D.tsx +2 -0
- package/src/component/2d/ft/Contours.tsx +3 -11
- package/src/component/2d/utilities/extractSpectrumSignals.ts +12 -9
- package/src/component/2d/zones/SignalsGuideLines.tsx +107 -11
- package/src/component/EventsTrackers/BrushTracker.tsx +2 -3
- package/src/component/assignment/AssignmentProvider.tsx +2 -1
- package/src/component/assignment/AssignmentsContext.ts +7 -2
- package/src/component/elements/SVGGroup.tsx +2 -2
- package/src/component/elements/Sections.tsx +103 -19
- package/src/component/elements/pdnd.cts +9 -0
- package/src/component/hooks/useToolsFunctions.ts +1 -1
- package/src/component/main/InnerNMRiumContents.tsx +3 -1
- package/src/component/modal/setting/settings-tabs/DatabasesTabContent.tsx +12 -7
- package/src/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.tsx +11 -5
- package/src/component/panels/MoleculesPanel/MoleculePanelHeader.tsx +32 -32
- package/src/component/panels/MoleculesPanel/Utilities.ts +2 -0
- package/src/component/panels/MoleculesPanel/useAtomAssignment.tsx +29 -8
- package/src/component/panels/Panels.tsx +9 -24
- package/src/component/panels/RangesPanel/RangesHeader.tsx +14 -21
- package/src/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.tsx +11 -1
- package/src/component/panels/filtersPanel/Filters/FiltersSectionsPanel.tsx +9 -0
- package/src/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.tsx +16 -18
- package/src/component/panels/hooks/useTogglePanel.ts +4 -3
- package/src/component/reducer/Reducer.ts +2 -0
- package/src/component/reducer/actions/FiltersActions.ts +86 -40
- package/src/component/reducer/actions/InsetActions.ts +1 -5
- package/src/component/reducer/actions/RangesActions.ts +10 -13
- package/src/component/reducer/actions/ToolsActions.ts +1 -2
- package/src/component/reducer/helper/ZoomHistoryManager.ts +20 -9
- package/src/component/reducer/preferences/actions/togglePanel.ts +10 -6
- package/src/component/reducer/preferences/preferencesReducer.ts +11 -1
- package/src/component/toolbar/ToolBar.tsx +2 -2
- package/src/component/toolbar/ToolTypes.ts +1 -1
- package/src/component/workspaces/exercise.ts +1 -1
- package/src/component/workspaces/prediction.ts +1 -1
- package/src/component/workspaces/workspaceDefaultProperties.ts +1 -1
- package/src/data/PredictionManager.ts +1 -0
- package/src/data/data2d/Spectrum2D/contours.ts +8 -4
- package/src/data/data2d/Spectrum2D/initiateDatum2D.ts +34 -16
- package/src/versionInfo.ts +1 -1
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { Popover } from '@blueprintjs/core';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import { IdcodeSvgRenderer } from 'react-ocl';
|
|
4
|
+
|
|
5
|
+
import { isSpectrum1D } from '../../data/data1d/Spectrum1D/isSpectrum1D.js';
|
|
6
|
+
import { useAssignment } from '../assignment/AssignmentsContext.js';
|
|
7
|
+
import type { AssignmentsData } from '../assignment/AssignmentsContext.js';
|
|
8
|
+
import { useScaleChecked } from '../context/ScaleContext.js';
|
|
9
|
+
import { HighlightEventSource, useHighlight } from '../highlight/index.js';
|
|
10
|
+
import useSpectrum from '../hooks/useSpectrum.js';
|
|
11
|
+
import useCheckExperimentalFeature from '../hooks/useCheckExperimentalFeature.js';
|
|
12
|
+
|
|
13
|
+
const boxHeight = 10;
|
|
14
|
+
const boxPadding = 4;
|
|
15
|
+
|
|
16
|
+
const Rect = styled.rect<{ isHighlighted: boolean }>`
|
|
17
|
+
fill: ${({ isHighlighted }) => (isHighlighted ? '#ff6f0057' : 'transparent')};
|
|
18
|
+
|
|
19
|
+
&:hover {
|
|
20
|
+
fill: #ff6f0057;
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
|
+
const Container = styled.div`
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
const InfoHeader = styled.div`
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: row;
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
const BaseText = styled.span`
|
|
34
|
+
text-align: center;
|
|
35
|
+
flex: 1;
|
|
36
|
+
font-size: 12px;
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
const Text = styled(BaseText)`
|
|
40
|
+
background-color: darkgray;
|
|
41
|
+
color: white;
|
|
42
|
+
`;
|
|
43
|
+
const Value = styled(BaseText)`
|
|
44
|
+
border-bottom: 1px solid darkgray;
|
|
45
|
+
font-weight: bold;
|
|
46
|
+
`;
|
|
47
|
+
interface Statistics {
|
|
48
|
+
min: number;
|
|
49
|
+
q1: number;
|
|
50
|
+
median: number;
|
|
51
|
+
q3: number;
|
|
52
|
+
max: number;
|
|
53
|
+
mean: number;
|
|
54
|
+
lowerWhisker: number;
|
|
55
|
+
upperWhisker: number;
|
|
56
|
+
nb: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface Metadata {
|
|
60
|
+
sphere: number;
|
|
61
|
+
hose: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface SignalStatistics {
|
|
65
|
+
statistics: Statistics;
|
|
66
|
+
metadata: Metadata;
|
|
67
|
+
id: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function useStatistics() {
|
|
71
|
+
const spectrum = useSpectrum();
|
|
72
|
+
|
|
73
|
+
if (!isSpectrum1D(spectrum)) return;
|
|
74
|
+
|
|
75
|
+
const ranges = spectrum?.ranges?.values;
|
|
76
|
+
if (!Array.isArray(ranges) || ranges?.length === 0) {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const result: SignalStatistics[] = [];
|
|
81
|
+
for (const range of ranges) {
|
|
82
|
+
const { signals = [] } = range;
|
|
83
|
+
for (const signal of signals) {
|
|
84
|
+
const { statistics, id, metadata } = signal as any;
|
|
85
|
+
if (!statistics) continue;
|
|
86
|
+
result.push({ id, statistics, metadata });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function PredictionErrorsNotations() {
|
|
94
|
+
const data = useStatistics();
|
|
95
|
+
|
|
96
|
+
if (!data || data?.length === 0) return null;
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<g transform={`translate(0,${boxHeight})`}>
|
|
100
|
+
{data.map((datum, index) => (
|
|
101
|
+
<g
|
|
102
|
+
key={datum.id}
|
|
103
|
+
transform={`translate(0,${index * (boxHeight + boxPadding * 2)})`}
|
|
104
|
+
>
|
|
105
|
+
<PredictionError {...datum} />
|
|
106
|
+
</g>
|
|
107
|
+
))}
|
|
108
|
+
</g>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function PredictionError(props: SignalStatistics) {
|
|
113
|
+
const { statistics, metadata, id } = props;
|
|
114
|
+
const isExperimental = useCheckExperimentalFeature();
|
|
115
|
+
const assignment = useAssignment(id);
|
|
116
|
+
const highlight = useHighlight(extractID(id, assignment), {
|
|
117
|
+
type: HighlightEventSource.SIGNAL,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const isAssignmentActive = assignment.isActive;
|
|
121
|
+
const isHighlighted = highlight.isActive || isAssignmentActive;
|
|
122
|
+
|
|
123
|
+
const { scaleX } = useScaleChecked();
|
|
124
|
+
const { min, max, median, q1, q3, nb } = statistics;
|
|
125
|
+
|
|
126
|
+
const yCenter = boxHeight / 2;
|
|
127
|
+
const yTop = 0;
|
|
128
|
+
const yBottom = boxHeight;
|
|
129
|
+
|
|
130
|
+
const xQ1 = scaleX()(q1);
|
|
131
|
+
const xQ3 = scaleX()(q3);
|
|
132
|
+
const xMin = scaleX()(min);
|
|
133
|
+
const xMax = scaleX()(max);
|
|
134
|
+
const xMedian = scaleX()(median);
|
|
135
|
+
|
|
136
|
+
const boxPath = `
|
|
137
|
+
M ${xMin} ${yCenter} L ${xQ1} ${yCenter}
|
|
138
|
+
M ${xQ1} ${yTop} L ${xQ3} ${yTop} L ${xQ3} ${yBottom} L ${xQ1} ${yBottom} Z
|
|
139
|
+
M ${xQ3} ${yCenter} L ${xMax} ${yCenter}
|
|
140
|
+
`;
|
|
141
|
+
|
|
142
|
+
const medianLine = `M ${xMedian} ${yTop} L ${xMedian} ${yBottom}`;
|
|
143
|
+
|
|
144
|
+
const rectWidth = Math.abs(xMax - xMin) + boxPadding * 2;
|
|
145
|
+
const rectHeight = boxHeight + boxPadding * 2;
|
|
146
|
+
const x = xMax - boxPadding;
|
|
147
|
+
const y = -boxPadding;
|
|
148
|
+
|
|
149
|
+
const { hose, sphere } = metadata;
|
|
150
|
+
return (
|
|
151
|
+
<Popover
|
|
152
|
+
targetTagName="g"
|
|
153
|
+
interactionKind="hover"
|
|
154
|
+
content={
|
|
155
|
+
isExperimental ? (
|
|
156
|
+
<InfoBlock hose={hose} sphere={sphere} nb={nb} />
|
|
157
|
+
) : undefined
|
|
158
|
+
}
|
|
159
|
+
>
|
|
160
|
+
<g
|
|
161
|
+
onMouseEnter={() => {
|
|
162
|
+
assignment.highlight('x');
|
|
163
|
+
highlight.show();
|
|
164
|
+
}}
|
|
165
|
+
onMouseLeave={() => {
|
|
166
|
+
assignment.clearHighlight();
|
|
167
|
+
highlight.hide();
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
<path d={boxPath} stroke="red" fill="transparent" strokeWidth={2} />
|
|
171
|
+
<path d={medianLine} stroke="red" strokeWidth={2} />
|
|
172
|
+
<Rect
|
|
173
|
+
x={x}
|
|
174
|
+
y={y}
|
|
175
|
+
width={rectWidth}
|
|
176
|
+
height={rectHeight}
|
|
177
|
+
data-no-export="true"
|
|
178
|
+
isHighlighted={isHighlighted}
|
|
179
|
+
/>
|
|
180
|
+
</g>
|
|
181
|
+
</Popover>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
interface InfoBlockProps {
|
|
186
|
+
sphere: number;
|
|
187
|
+
nb: number;
|
|
188
|
+
hose: string;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function InfoBlock(props: InfoBlockProps) {
|
|
192
|
+
const { sphere, nb, hose } = props;
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
<Container>
|
|
196
|
+
<InfoHeader>
|
|
197
|
+
<Text>Sphere</Text>
|
|
198
|
+
<Value>{sphere}</Value>
|
|
199
|
+
<Text>Nb</Text>
|
|
200
|
+
<Value>{nb}</Value>
|
|
201
|
+
</InfoHeader>
|
|
202
|
+
{hose && <IdcodeSvgRenderer idcode={hose} />}
|
|
203
|
+
</Container>
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function extractID(id: string, assignment: AssignmentsData) {
|
|
208
|
+
return [id].concat(assignment.assignedDiaIds?.x || []);
|
|
209
|
+
}
|
|
@@ -4,6 +4,7 @@ import SpectrumInfoBlock from '../1d-2d/components/SpectrumInfoBlock.js';
|
|
|
4
4
|
import { ApodizationLine } from './ApodizationLine.js';
|
|
5
5
|
import ExclusionZonesAnnotations from './ExclusionZonesAnnotations.js';
|
|
6
6
|
import LinesSeries from './LinesSeries.js';
|
|
7
|
+
import { PredictionErrorsNotations } from './PredictionErrorsNotations.js';
|
|
7
8
|
import SimilarityTree from './SimilarityTree.js';
|
|
8
9
|
import SpectraTracker from './SpectraLegends.js';
|
|
9
10
|
import { XAxis1D } from './XAxis1D.js';
|
|
@@ -45,6 +46,7 @@ export function SVGContent1D() {
|
|
|
45
46
|
<SimilarityTree />
|
|
46
47
|
</ClipPathContainer>
|
|
47
48
|
<JGraph />
|
|
49
|
+
<PredictionErrorsNotations />
|
|
48
50
|
|
|
49
51
|
<g className="container" style={{ pointerEvents: 'none' }}>
|
|
50
52
|
<XAxis1D />
|
|
@@ -3,10 +3,7 @@ import debounce from 'lodash/debounce.js';
|
|
|
3
3
|
import { memo, useMemo, useRef } from 'react';
|
|
4
4
|
|
|
5
5
|
import type { LevelSign } from '../../../data/data2d/Spectrum2D/contours.js';
|
|
6
|
-
import {
|
|
7
|
-
drawContours,
|
|
8
|
-
getDefaultContoursLevel,
|
|
9
|
-
} from '../../../data/data2d/Spectrum2D/contours.js';
|
|
6
|
+
import { drawContours } from '../../../data/data2d/Spectrum2D/contours.js';
|
|
10
7
|
import { useChartData } from '../../context/ChartContext.js';
|
|
11
8
|
import { usePreferences } from '../../context/PreferencesContext.js';
|
|
12
9
|
import { useToaster } from '../../context/ToasterContext.js';
|
|
@@ -52,16 +49,11 @@ function usePath(
|
|
|
52
49
|
return pathBuilder.toString();
|
|
53
50
|
}
|
|
54
51
|
|
|
55
|
-
const useContoursLevel = (
|
|
56
|
-
spectrum: Spectrum2D,
|
|
57
|
-
sign: LevelSign,
|
|
58
|
-
quadrant = 'rr',
|
|
59
|
-
) => {
|
|
52
|
+
const useContoursLevel = (spectrum: Spectrum2D, sign: LevelSign) => {
|
|
60
53
|
const {
|
|
61
54
|
display: { contourOptions },
|
|
62
55
|
} = spectrum;
|
|
63
|
-
|
|
64
|
-
return level ?? getDefaultContoursLevel(spectrum, quadrant)[sign];
|
|
56
|
+
return contourOptions?.[sign];
|
|
65
57
|
};
|
|
66
58
|
|
|
67
59
|
function ContoursPaths({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Spectrum1D } from '@zakodium/nmrium-core';
|
|
2
|
+
import type { Range } from 'nmr-processing';
|
|
2
3
|
|
|
3
4
|
import { SIGNAL_INCLUDED_KINDS } from '../../../data/constants/signalsKinds.js';
|
|
4
5
|
|
|
@@ -6,19 +7,21 @@ export interface BaseSignal {
|
|
|
6
7
|
assignment?: string;
|
|
7
8
|
delta: number;
|
|
8
9
|
id: string;
|
|
9
|
-
rangeId: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
export type ExtractedSignal<T> = BaseSignal & T;
|
|
13
|
+
|
|
14
|
+
interface ExtractSpectrumSignalsOptions<T> {
|
|
13
15
|
from?: number;
|
|
14
16
|
to?: number;
|
|
17
|
+
include?: (range: Range) => T;
|
|
15
18
|
}
|
|
16
|
-
export function extractSpectrumSignals(
|
|
19
|
+
export function extractSpectrumSignals<T extends object = object>(
|
|
17
20
|
spectrum: Spectrum1D,
|
|
18
|
-
options: ExtractSpectrumSignalsOptions = {},
|
|
21
|
+
options: ExtractSpectrumSignalsOptions<T> = {},
|
|
19
22
|
) {
|
|
20
|
-
const result:
|
|
21
|
-
const { from, to } = options;
|
|
23
|
+
const result: Array<ExtractedSignal<T>> = [];
|
|
24
|
+
const { from, to, include } = options;
|
|
22
25
|
|
|
23
26
|
const ranges = spectrum?.ranges?.values;
|
|
24
27
|
if (!Array.isArray(ranges) || ranges?.length === 0) {
|
|
@@ -40,7 +43,7 @@ export function extractSpectrumSignals(
|
|
|
40
43
|
|
|
41
44
|
if (!isInRange) continue;
|
|
42
45
|
|
|
43
|
-
const { assignment, signals = []
|
|
46
|
+
const { assignment, signals = [] } = range;
|
|
44
47
|
let index = 0;
|
|
45
48
|
for (const signal of signals) {
|
|
46
49
|
const { id, delta, kind } = signal;
|
|
@@ -49,8 +52,8 @@ export function extractSpectrumSignals(
|
|
|
49
52
|
assignment: index === 0 ? assignment : '',
|
|
50
53
|
delta,
|
|
51
54
|
id,
|
|
52
|
-
|
|
53
|
-
});
|
|
55
|
+
...include?.(range),
|
|
56
|
+
} as ExtractedSignal<T>);
|
|
54
57
|
index++;
|
|
55
58
|
}
|
|
56
59
|
}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
2
|
import type { Spectrum1D } from '@zakodium/nmrium-core';
|
|
3
|
+
import type { Range } from 'nmr-processing';
|
|
4
|
+
import { useRef } from 'react';
|
|
5
|
+
import { LuLink, LuUnlink } from 'react-icons/lu';
|
|
3
6
|
import { PiTextTBold, PiTextTSlashBold } from 'react-icons/pi';
|
|
4
7
|
|
|
5
8
|
import { FieldEdition } from '../../1d-2d/FieldEdition.js';
|
|
9
|
+
import {
|
|
10
|
+
useAssignment,
|
|
11
|
+
useAssignmentContext,
|
|
12
|
+
} from '../../assignment/AssignmentsContext.js';
|
|
13
|
+
import { filterAssignedIDs } from '../../assignment/utilities/filterAssignedIDs.js';
|
|
6
14
|
import { useChartData } from '../../context/ChartContext.js';
|
|
7
15
|
import { useDispatch } from '../../context/DispatchContext.js';
|
|
8
16
|
import {
|
|
@@ -11,16 +19,17 @@ import {
|
|
|
11
19
|
} from '../../context/ShareDataContext.js';
|
|
12
20
|
import { ActionsButtonsPopover } from '../../elements/ActionsButtonsPopover.js';
|
|
13
21
|
import type { ActionsButtonsPopoverProps } from '../../elements/ActionsButtonsPopover.js';
|
|
22
|
+
import { HighlightEventSource, useHighlight } from '../../highlight/index.js';
|
|
14
23
|
import { useCanvasContext } from '../../hooks/useCanvasContext.js';
|
|
15
24
|
import { useTriggerNewAssignmentLabel } from '../../hooks/useTriggerNewAssignmentLabel.js';
|
|
16
25
|
import { stackOverlappingLabelsArray } from '../../utility/stackOverlappingLabels.js';
|
|
17
26
|
import { useTracesSpectra } from '../useTracesSpectra.js';
|
|
18
27
|
import { extractSpectrumSignals } from '../utilities/extractSpectrumSignals.js';
|
|
19
|
-
import type {
|
|
28
|
+
import type { ExtractedSignal } from '../utilities/extractSpectrumSignals.js';
|
|
20
29
|
import { useScale2DX, useScale2DY } from '../utilities/scale.js';
|
|
21
30
|
|
|
22
|
-
const Rect = styled.rect
|
|
23
|
-
fill: transparent;
|
|
31
|
+
const Rect = styled.rect<{ isActive: boolean }>`
|
|
32
|
+
fill: ${({ isActive }) => (isActive ? '#ff6f0057' : 'transparent')};
|
|
24
33
|
|
|
25
34
|
&:hover {
|
|
26
35
|
fill: #ff6f0057;
|
|
@@ -42,13 +51,18 @@ interface IndicationLinesProps extends SignalsGuideLinesProps {
|
|
|
42
51
|
const labelSize = 12;
|
|
43
52
|
const padding = 2;
|
|
44
53
|
|
|
45
|
-
interface
|
|
54
|
+
interface ExtraExtractProperties {
|
|
55
|
+
range: Range;
|
|
56
|
+
}
|
|
57
|
+
interface ProcessedSignal extends ExtractedSignal<ExtraExtractProperties> {
|
|
46
58
|
labelWidth: number;
|
|
47
59
|
deltaInPixel: number;
|
|
48
60
|
}
|
|
49
61
|
|
|
50
62
|
function useSignalsOverlap(axis: IndicationLinesAxis, spectrum: Spectrum1D) {
|
|
51
|
-
const signals = extractSpectrumSignals(spectrum
|
|
63
|
+
const signals = extractSpectrumSignals<ExtraExtractProperties>(spectrum, {
|
|
64
|
+
include: (range) => ({ range }),
|
|
65
|
+
});
|
|
52
66
|
const scaleX = useScale2DX();
|
|
53
67
|
const scaleY = useScale2DY();
|
|
54
68
|
const context = useCanvasContext(labelSize);
|
|
@@ -87,13 +101,14 @@ function IndicationLines(props: IndicationLinesProps) {
|
|
|
87
101
|
return (
|
|
88
102
|
<g>
|
|
89
103
|
{normalizedSignals.map(
|
|
90
|
-
({ deltaInPixel, stackIndex, assignment, id,
|
|
104
|
+
({ deltaInPixel, stackIndex, assignment, id, range }) => {
|
|
91
105
|
return (
|
|
92
106
|
<IndicationLine
|
|
93
107
|
key={`${axis}[${id}]`}
|
|
94
|
-
{...{ deltaInPixel, stackIndex, assignment, id
|
|
108
|
+
{...{ deltaInPixel, stackIndex, assignment, id }}
|
|
95
109
|
axis={axis}
|
|
96
110
|
spectrumId={spectrum.id}
|
|
111
|
+
range={range}
|
|
97
112
|
/>
|
|
98
113
|
);
|
|
99
114
|
},
|
|
@@ -102,11 +117,10 @@ function IndicationLines(props: IndicationLinesProps) {
|
|
|
102
117
|
);
|
|
103
118
|
}
|
|
104
119
|
|
|
105
|
-
interface IndicationLineProps {
|
|
120
|
+
interface IndicationLineProps extends ExtraExtractProperties {
|
|
106
121
|
deltaInPixel: number;
|
|
107
122
|
stackIndex: number;
|
|
108
123
|
assignment?: string;
|
|
109
|
-
rangeId: string;
|
|
110
124
|
spectrumId: string;
|
|
111
125
|
axis: IndicationLinesAxis;
|
|
112
126
|
}
|
|
@@ -121,12 +135,45 @@ function getAxisRangeId(options: GetAxisRangeIdOptions) {
|
|
|
121
135
|
return `${axis}[${rangeId}]`;
|
|
122
136
|
}
|
|
123
137
|
|
|
138
|
+
interface UseRangeAssignmentOptions {
|
|
139
|
+
rangeId: string;
|
|
140
|
+
signalsIds: string[];
|
|
141
|
+
spectrumId: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function useRangeAssignment(options: UseRangeAssignmentOptions) {
|
|
145
|
+
const { rangeId, signalsIds, spectrumId } = options;
|
|
146
|
+
|
|
147
|
+
const assignmentData = useAssignmentContext();
|
|
148
|
+
const assignmentContext = useAssignment(rangeId, spectrumId);
|
|
149
|
+
const highlightId = [rangeId]
|
|
150
|
+
.concat(assignmentContext.assignedDiaIds?.x || [])
|
|
151
|
+
.concat(filterAssignedIDs(assignmentData.data, signalsIds));
|
|
152
|
+
|
|
153
|
+
const highlightContext = useHighlight(highlightId, {
|
|
154
|
+
type: HighlightEventSource.RANGE,
|
|
155
|
+
extra: { id: rangeId, spectrumID: spectrumId },
|
|
156
|
+
});
|
|
157
|
+
return { highlightContext, assignmentContext };
|
|
158
|
+
}
|
|
159
|
+
|
|
124
160
|
function IndicationLine(props: IndicationLineProps) {
|
|
125
|
-
const
|
|
161
|
+
const isAssignBtnTrigged = useRef(false);
|
|
162
|
+
const { deltaInPixel, stackIndex, assignment, axis, spectrumId, range } =
|
|
126
163
|
props;
|
|
164
|
+
const { id: rangeId, diaIDs = [], signals } = range;
|
|
165
|
+
const signalsIds = signals.map(({ id }) => id);
|
|
127
166
|
const { margin, width, height } = useChartData();
|
|
128
167
|
const { setData: addNewAssignmentLabel } = useShareData();
|
|
129
168
|
const dispatch = useDispatch();
|
|
169
|
+
const { assignmentContext, highlightContext } = useRangeAssignment({
|
|
170
|
+
rangeId,
|
|
171
|
+
spectrumId,
|
|
172
|
+
signalsIds,
|
|
173
|
+
});
|
|
174
|
+
const hasDiaIDs = diaIDs.length > 0;
|
|
175
|
+
const isAssignmentActive = assignmentContext.isActive;
|
|
176
|
+
const isHighlighted = highlightContext.isActive || isAssignmentActive;
|
|
130
177
|
|
|
131
178
|
const innerWidth = width - margin.left - margin.right;
|
|
132
179
|
const innerHeight = height - margin.top - margin.bottom;
|
|
@@ -157,7 +204,45 @@ function IndicationLine(props: IndicationLineProps) {
|
|
|
157
204
|
});
|
|
158
205
|
}
|
|
159
206
|
|
|
207
|
+
function mouseEnterHandler() {
|
|
208
|
+
assignmentContext.highlight('x');
|
|
209
|
+
highlightContext.show();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function mouseLeaveHandler() {
|
|
213
|
+
assignmentContext.clearHighlight();
|
|
214
|
+
highlightContext.hide();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function assignHandler() {
|
|
218
|
+
isAssignBtnTrigged.current = true;
|
|
219
|
+
assignmentContext.activate('x');
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function unAssignHandler() {
|
|
223
|
+
dispatch({
|
|
224
|
+
type: 'UNLINK_RANGE',
|
|
225
|
+
payload: {
|
|
226
|
+
rangeKey: rangeId,
|
|
227
|
+
spectrumId,
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
160
232
|
const actionsButtons: ActionsButtonsPopoverProps['buttons'] = [
|
|
233
|
+
{
|
|
234
|
+
icon: <LuLink />,
|
|
235
|
+
onClick: assignHandler,
|
|
236
|
+
intent: 'success',
|
|
237
|
+
title: 'Assign range',
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
icon: <LuUnlink />,
|
|
241
|
+
onClick: () => unAssignHandler(),
|
|
242
|
+
intent: 'danger',
|
|
243
|
+
title: 'Unassign range',
|
|
244
|
+
visible: !!(isAssignmentActive || hasDiaIDs),
|
|
245
|
+
},
|
|
161
246
|
{
|
|
162
247
|
icon: <PiTextTBold />,
|
|
163
248
|
onClick: () => addNewAssignmentLabel(getAxisRangeId({ axis, rangeId })),
|
|
@@ -174,14 +259,24 @@ function IndicationLine(props: IndicationLineProps) {
|
|
|
174
259
|
},
|
|
175
260
|
];
|
|
176
261
|
|
|
262
|
+
const isOpen = isAssignBtnTrigged.current ? isAssignmentActive : undefined;
|
|
263
|
+
|
|
177
264
|
return (
|
|
178
265
|
<ActionsButtonsPopover
|
|
266
|
+
isOpen={isOpen}
|
|
179
267
|
targetTagName="g"
|
|
180
268
|
buttons={actionsButtons}
|
|
181
269
|
space={2}
|
|
182
270
|
position={isOverXAxis ? 'right-top' : 'top-left'}
|
|
271
|
+
onClosed={() => {
|
|
272
|
+
isAssignBtnTrigged.current = false;
|
|
273
|
+
}}
|
|
183
274
|
>
|
|
184
|
-
<g
|
|
275
|
+
<g
|
|
276
|
+
transform={`translate(${x},${y})`}
|
|
277
|
+
onMouseEnter={mouseEnterHandler}
|
|
278
|
+
onMouseLeave={mouseLeaveHandler}
|
|
279
|
+
>
|
|
185
280
|
<line stroke="lightgrey" x1={0} x2={x2} y1={0} y2={y2} />
|
|
186
281
|
<Rect
|
|
187
282
|
x={-rectXOffset}
|
|
@@ -189,6 +284,7 @@ function IndicationLine(props: IndicationLineProps) {
|
|
|
189
284
|
width={rectWidth}
|
|
190
285
|
height={rectHeight}
|
|
191
286
|
data-no-export="true"
|
|
287
|
+
isActive={isHighlighted}
|
|
192
288
|
/>
|
|
193
289
|
<AssignmentLabel
|
|
194
290
|
x={labelX}
|
|
@@ -498,10 +498,9 @@ export function detectBrushing(
|
|
|
498
498
|
const scaleY = (endY - startY) / height;
|
|
499
499
|
const scaleX = (endX - startX) / width;
|
|
500
500
|
if (thresholdAxis === 'y') {
|
|
501
|
-
if (yDiff >= yThreshold) {
|
|
501
|
+
if (yDiff >= yThreshold && yThreshold > 0) {
|
|
502
502
|
return { type: 'XY', startX, startY, endX, endY, scaleX, scaleY };
|
|
503
503
|
}
|
|
504
|
-
|
|
505
504
|
return {
|
|
506
505
|
type: 'X',
|
|
507
506
|
startX,
|
|
@@ -513,7 +512,7 @@ export function detectBrushing(
|
|
|
513
512
|
};
|
|
514
513
|
}
|
|
515
514
|
if (thresholdAxis === 'x') {
|
|
516
|
-
if (xDiff >= xThreshold) {
|
|
515
|
+
if (xDiff >= xThreshold && xThreshold > 0) {
|
|
517
516
|
return { type: 'XY', startX, startY, endX, endY, scaleX, scaleY };
|
|
518
517
|
}
|
|
519
518
|
|
|
@@ -24,10 +24,11 @@ export function AssignmentProvider(props: AssignmentProviderProps) {
|
|
|
24
24
|
|
|
25
25
|
const memoState = useMemo<AssignmentContext>(() => {
|
|
26
26
|
const activate = (options: ActivateAssignmentOptions) => {
|
|
27
|
+
const { id, axis, spectrumId } = options;
|
|
27
28
|
setState((prevState) => ({
|
|
28
29
|
...prevState,
|
|
29
30
|
activated: !prevState.activated
|
|
30
|
-
? { id
|
|
31
|
+
? { id, axis: axis || null, spectrumId }
|
|
31
32
|
: null,
|
|
32
33
|
}));
|
|
33
34
|
};
|
|
@@ -32,6 +32,7 @@ export interface HighlightAssignmentOptions {
|
|
|
32
32
|
export interface ActivateAssignmentOptions {
|
|
33
33
|
id: string;
|
|
34
34
|
axis: Axis;
|
|
35
|
+
spectrumId?: string;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
export const assignmentStatus: AssignmentStatus = {
|
|
@@ -40,7 +41,7 @@ export const assignmentStatus: AssignmentStatus = {
|
|
|
40
41
|
};
|
|
41
42
|
|
|
42
43
|
export interface AssignmentStatus {
|
|
43
|
-
activated: AssignmentItem | null;
|
|
44
|
+
activated: (AssignmentItem & { spectrumId?: string }) | null;
|
|
44
45
|
highlighted: AssignmentItem | null;
|
|
45
46
|
}
|
|
46
47
|
export interface AssignmentContext extends AssignmentStatus {
|
|
@@ -82,7 +83,10 @@ export function useAssignmentContext() {
|
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
// key can be signal id,range id or zone id
|
|
85
|
-
export function useAssignment(
|
|
86
|
+
export function useAssignment(
|
|
87
|
+
id: string,
|
|
88
|
+
spectrumId?: string,
|
|
89
|
+
): AssignmentsData {
|
|
86
90
|
const { data, activated, highlighted, activate, highlight, clearHighlight } =
|
|
87
91
|
useAssignmentContext();
|
|
88
92
|
|
|
@@ -93,6 +97,7 @@ export function useAssignment(id: string): AssignmentsData {
|
|
|
93
97
|
function activateAssignment(axis: Axis) {
|
|
94
98
|
if (id) {
|
|
95
99
|
activate({
|
|
100
|
+
spectrumId,
|
|
96
101
|
id,
|
|
97
102
|
axis,
|
|
98
103
|
});
|
|
@@ -8,7 +8,7 @@ interface SVGGroupProps extends SVGAttributes<SVGElement> {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export function SVGGroup(props: SVGGroupProps) {
|
|
11
|
-
const elementsRefs = useRef<
|
|
11
|
+
const elementsRefs = useRef<SVGGraphicsElement[]>([]);
|
|
12
12
|
const { children, direction = 'row', space = 0, ...resProps } = props;
|
|
13
13
|
|
|
14
14
|
useLayoutEffect(() => {
|
|
@@ -21,7 +21,7 @@ export function SVGGroup(props: SVGGroupProps) {
|
|
|
21
21
|
|
|
22
22
|
for (const element of elements) {
|
|
23
23
|
if (element) {
|
|
24
|
-
const boundary = element.
|
|
24
|
+
const boundary = element.getBBox();
|
|
25
25
|
if (direction === 'row') {
|
|
26
26
|
element.setAttribute('transform', `translate(${shift} 0)`);
|
|
27
27
|
shift += boundary.width + space;
|