Skip to content

Commit

Permalink
- fixed scenario when there are no actions for ngl view settings modi…
Browse files Browse the repository at this point in the history
…fication but ngl view was modified by mouse controls

- updated version number
  • Loading branch information
boriskovar-m2ms committed Jan 26, 2021
1 parent 7b5b6e5 commit 1c4dfba
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 15 deletions.
9 changes: 9 additions & 0 deletions js/components/nglView/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,12 @@ export const MOL_REPRESENTATION = {
};

export const MOL_REPRESENTATION_BUFFER = 'buffer';

export const NGL_VIEW_DEFAULT_VALUES = {
[NGL_PARAMS.backgroundColor]: BACKGROUND_COLOR.black,
[NGL_PARAMS.clipNear]: 42,
[NGL_PARAMS.clipFar]: 100,
[NGL_PARAMS.clipDist]: 10,
[NGL_PARAMS.fogNear]: 50,
[NGL_PARAMS.fogFar]: 62
};
15 changes: 8 additions & 7 deletions js/reducers/ngl/nglReducers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BACKGROUND_COLOR, NGL_PARAMS } from '../../components/nglView/constants';
import { BACKGROUND_COLOR, NGL_PARAMS, NGL_VIEW_DEFAULT_VALUES } from '../../components/nglView/constants';
import { CONSTANTS } from './constants';
import { VIEWS } from '../../constants/constants';

Expand All @@ -23,12 +23,13 @@ export const INITIAL_STATE = {
[NGL_PARAMS.ambientColor]: 0xdddddd,
[NGL_PARAMS.ambientIntensity]: 0.2,
[NGL_PARAMS.hoverTimeout]: 0, */
[NGL_PARAMS.backgroundColor]: BACKGROUND_COLOR.black,
[NGL_PARAMS.clipNear]: 42,
[NGL_PARAMS.clipFar]: 100,
[NGL_PARAMS.clipDist]: 10,
[NGL_PARAMS.fogNear]: 50,
[NGL_PARAMS.fogFar]: 62
...NGL_VIEW_DEFAULT_VALUES
// [NGL_PARAMS.backgroundColor]: BACKGROUND_COLOR.black,
// [NGL_PARAMS.clipNear]: 42,
// [NGL_PARAMS.clipFar]: 100,
// [NGL_PARAMS.clipDist]: 10,
// [NGL_PARAMS.fogNear]: 50,
// [NGL_PARAMS.fogFar]: 62
},

// Helper variables for marking that protein and molecule groups are successful loaded
Expand Down
26 changes: 19 additions & 7 deletions js/reducers/tracking/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import {
updateComponentRepresentationVisibilityAll,
changeComponentRepresentation
} from '../../../js/reducers/ngl/actions';
import { NGL_PARAMS } from '../../components/nglView/constants';
import { NGL_PARAMS, NGL_VIEW_DEFAULT_VALUES } from '../../components/nglView/constants';
import * as listType from '../../constants/listTypes';
import { assignRepresentationToComp } from '../../components/nglView/generatingObjects';
import {
Expand Down Expand Up @@ -731,39 +731,51 @@ export const restoreNglViewSettings = stages => (dispatch, getState) => {
const orderedActionList = currentActionList.reverse((a, b) => a.timestamp - b.timestamp);

let backgroundAction = orderedActionList.find(action => action.type === actionType.BACKGROUND_COLOR_CHANGED);
if (backgroundAction && backgroundAction.newSetting) {
if (backgroundAction && backgroundAction.newSetting !== undefined) {
let value = backgroundAction.newSetting;
dispatch(setNglBckGrndColor(value, majorView, summaryView));
} else {
dispatch(setNglBckGrndColor(NGL_VIEW_DEFAULT_VALUES[NGL_PARAMS.backgroundColor], majorView, summaryView));
}

let clipNearAction = orderedActionList.find(action => action.type === actionType.CLIP_NEAR);
if (clipNearAction && clipNearAction.newSetting) {
if (clipNearAction && clipNearAction.newSetting !== undefined) {
let value = clipNearAction.newSetting;
dispatch(setNglClipNear(value, viewParams[NGL_PARAMS.clipNear], majorView));
} else {
dispatch(setNglClipNear(NGL_VIEW_DEFAULT_VALUES[NGL_PARAMS.clipNear], viewParams[NGL_PARAMS.clipNear], majorView));
}

let clipFarAction = orderedActionList.find(action => action.type === actionType.CLIP_FAR);
if (clipFarAction && clipFarAction.newSetting) {
if (clipFarAction && clipFarAction.newSetting !== undefined) {
let value = clipFarAction.newSetting;
dispatch(setNglClipFar(value, viewParams[NGL_PARAMS.clipFar], majorView));
} else {
dispatch(setNglClipFar(NGL_VIEW_DEFAULT_VALUES[NGL_PARAMS.clipFar], viewParams[NGL_PARAMS.clipFar], majorView));
}

let clipDistAction = orderedActionList.find(action => action.type === actionType.CLIP_DIST);
if (clipDistAction && clipDistAction.newSetting) {
if (clipDistAction && clipDistAction.newSetting !== undefined) {
let value = clipDistAction.newSetting;
dispatch(setNglClipDist(value, viewParams[NGL_PARAMS.clipDist], majorView));
} else {
dispatch(setNglClipDist(NGL_VIEW_DEFAULT_VALUES[NGL_PARAMS.clipDist], viewParams[NGL_PARAMS.clipDist], majorView));
}

let fogNearAction = orderedActionList.find(action => action.type === actionType.FOG_NEAR);
if (fogNearAction && fogNearAction.newSetting) {
if (fogNearAction && fogNearAction.newSetting !== undefined) {
let value = fogNearAction.newSetting;
dispatch(setNglFogNear(value, viewParams[NGL_PARAMS.fogNear], majorView));
} else {
dispatch(setNglFogNear(NGL_VIEW_DEFAULT_VALUES[NGL_PARAMS.fogNear], viewParams[NGL_PARAMS.fogNear], majorView));
}

let fogFarAction = orderedActionList.find(action => action.type === actionType.FOG_FAR);
if (fogFarAction && fogFarAction.newSetting) {
if (fogFarAction && fogFarAction.newSetting !== undefined) {
let value = fogFarAction.newSetting;
dispatch(setNglFogFar(value, viewParams[NGL_PARAMS.fogFar], majorView));
} else {
dispatch(setNglFogFar(NGL_VIEW_DEFAULT_VALUES[NGL_PARAMS.fogFar], viewParams[NGL_PARAMS.fogFar], majorView));
}
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fragalysis-frontend",
"version": "0.9.48",
"version": "0.9.50",
"description": "Frontend for fragalysis",
"main": "webpack.config.js",
"scripts": {
Expand Down

0 comments on commit 1c4dfba

Please sign in to comment.