Skip to content

feat(integration): two-click creation, split, and visual split with JCAMP persistence#303

Merged
PiTrem merged 8 commits into
masterfrom
feat/integration-baseline-separation
Jun 23, 2026
Merged

feat(integration): two-click creation, split, and visual split with JCAMP persistence#303
PiTrem merged 8 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 Nicolass67 marked this pull request as ready for review June 12, 2026 08:51
@Nicolass67 Nicolass67 requested a review from headri June 12, 2026 08:52
@PiTrem PiTrem requested a review from Copilot June 15, 2026 12:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/reducers/reducer_integration.js Outdated
Nicolass67 and others added 7 commits June 19, 2026 13:50
- 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.
@headri headri force-pushed the feat/integration-baseline-separation branch from dcb5c06 to 29982c5 Compare June 19, 2026 13:12
@headri headri self-requested a review June 19, 2026 13:14
@PiTrem PiTrem changed the title Integration baseline separation feat(integration): two-click creation, split, and visual split with JCAMP persistence Jun 23, 2026

@PiTrem PiTrem left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two-click integration creation plus regular and visual split tools with JCAMP persistence; CI green.

@PiTrem PiTrem merged commit 0ce405a into master Jun 23, 2026
2 checks passed
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.

4 participants