Skip to content

Integration baseline separation#303

Draft
Nicolass67 wants to merge 4 commits into
masterfrom
feat/integration-baseline-separation
Draft

Integration baseline separation#303
Nicolass67 wants to merge 4 commits into
masterfrom
feat/integration-baseline-separation

Conversation

@Nicolass67
Copy link
Copy Markdown
Contributor

PR description

Context

Before this branch, an integration could only be added by sweeping over a range (click-and-drag), removed, referenced or cleared. There was no way to subdivide an existing integration: if a peak ended up containing two signals, users had to delete the integration and redraw both halves by hand. That was tedious, lost the reference factor, and made the raw integration values flicker between two states with no way to relate them to each other.

This PR reworks the way integrations are created and introduces two complementary split tools so users can subdivide an integration depending on what they want to express.

What's in this PR

1. Two-click integration creation

Adding an integration is no longer done with a sweep. The user now clicks a first point to anchor the start of the integration (a live preview follows the cursor), then clicks a second point to commit it. The previous click-and-drag sweep is removed for integrations.

This makes the boundaries easier to place precisely on noisy or dense spectra and matches the interaction model used by the new split tools below.

2. Regular split

A new Split Integration toolbar button. Clicking on an integration drops a vertical cut at the cursor position and replaces it with two independent integrations. Each new integration recomputes its area from the raw data, so the values reflect the true area under the curve of each half. Use this when the two halves are genuinely separate signals whose areas should stand on their own.

3. Visual split

A new Visual Split toolbar button. Clicking on an integration drops a red dashed line and splits it into two visually linked children that share a visualSplitGroupId. Use this when both halves still belong to the same chemical group but you want to see their individual contributions without losing the total.

Key properties:

  • The original total area is preserved: the two children's areas sum back to the original (splitAreaProportionally).
  • An integration can be visually split only once. Clicking again on the merged group has no effect.
  • Clicking on an existing red line removes it and merges the two children back into one integration.
  • A child of a visual split group can still be regularly split: the part farther from the red line is extracted as an independent integration, the part adjacent to the red line stays in the group, and the original red line position is preserved.

4. JCAMP persistence

$OBSERVEDINTEGRALSGROUPS records read/write the visualSplitGroupId of each integration, so visual splits survive save/reload through ChemSpectra. The parser is robust against the optional leading newline emitted by jcampconverter.

Nicolass67 added 4 commits May 8, 2026 11:29
- Implemented `splitIntegration` action in integration actions.
- Added tests for the new split integration functionality in `integration.test.tsx`.
- Enhanced integration helper functions to support split integration logic.
- Updated UI components to handle split integration state and actions.
- Introduced new constants for integration split in action types and UI sweep types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant