Skip to content

Commit

Permalink
feat: change contours levels for all 2d spectra if no spectrum is sel…
Browse files Browse the repository at this point in the history
…ected (#2074)

close #2069
  • Loading branch information
hamed-musallam committed Jan 17, 2023
1 parent da4a446 commit ce89796
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/component/reducer/actions/ToolsActions.ts
Expand Up @@ -10,6 +10,7 @@ import { LAYOUT } from '../../2d/utilities/DimensionLayout';
import { get2DYScale } from '../../2d/utilities/scale';
import { options } from '../../toolbar/ToolTypes';
import groupByInfoKey from '../../utility/GroupByInfoKey';
import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
import { rangeStateInit, State } from '../Reducer';
import { DISPLAYER_MODE, MARGIN } from '../core/Constants';
import { setZoom, wheelZoom, ZoomType } from '../helper/Zoom1DManager';
Expand Down Expand Up @@ -463,13 +464,23 @@ function handelSetActiveTab(draft: Draft<State>, tab) {
}

function levelChangeHandler(draft: Draft<State>, { deltaY, shiftKey }) {
const {
data,
view: {
spectra: { activeTab },
zoom: { levels },
},
} = draft;
const activeSpectrum = getSpectrum(draft) as Datum2D;
try {
if (activeSpectrum?.id) {
const { levels } = draft.view.zoom;
const contourOptions = activeSpectrum.display.contourOptions;
const zoom = contoursManager(activeSpectrum.id, levels, contourOptions);
levels[activeSpectrum.id] = zoom.wheel(deltaY, shiftKey);
const spectra = activeSpectrum?.id
? [activeSpectrum]
: getSpectraByNucleus(activeTab, data);

for (const spectrum of spectra as Datum2D[]) {
const contourOptions = spectrum.display.contourOptions;
const zoom = contoursManager(spectrum.id, levels, contourOptions);
levels[spectrum.id] = zoom.wheel(deltaY, shiftKey);
}
} catch (error) {
// TODO: handle error.
Expand Down

0 comments on commit ce89796

Please sign in to comment.