Skip to content

Commit

Permalink
- finished implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskovar-m2ms committed Jan 20, 2021
1 parent 108114e commit 655ed84
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 12 deletions.
10 changes: 5 additions & 5 deletions js/components/preview/viewerControls/settingsControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Drawer } from '../../common/Navigation/Drawer';
import { BACKGROUND_COLOR, NGL_PARAMS } from '../../nglView/constants';
import { useDispatch, useSelector } from 'react-redux';
import { setNglViewParams } from '../../../reducers/ngl/actions';
import { setNglBckGrndColor, setNglClipNear } from '../../../reducers/ngl/dispatchActions';
import { setNglBckGrndColor, setNglClipNear, setNglClipFar, setNglClipDist, setNglFogNear, setNglFogFar } from '../../../reducers/ngl/dispatchActions';
import { NglContext } from '../../nglView/nglProvider';
import { VIEWS } from '../../../constants/constants';

Expand Down Expand Up @@ -86,7 +86,7 @@ export const SettingControls = memo(({ open, onClose }) => {
step={1}
min={0}
max={100}
onChange={(e, value) => dispatch(setNglViewParams(NGL_PARAMS.clipFar, value, majorView, VIEWS.MAJOR_VIEW))}
onChange={(e, value) => dispatch(setNglClipFar(value, viewParams[NGL_PARAMS.cli], majorView))}
/>
</Grid>
</Grid>
Expand All @@ -98,7 +98,7 @@ export const SettingControls = memo(({ open, onClose }) => {
<TextField
type="number"
value={viewParams[NGL_PARAMS.clipDist]}
onChange={e => dispatch(setNglViewParams(NGL_PARAMS.clipDist, e.target.value, majorView, VIEWS.MAJOR_VIEW))}
onChange={e => dispatch(setNglClipDist(e.target.value, viewParams[NGL_PARAMS.clipDist], majorView))}
className={classes.textField}
/>
</Grid>
Expand All @@ -114,7 +114,7 @@ export const SettingControls = memo(({ open, onClose }) => {
step={1}
min={0}
max={100}
onChange={(e, value) => dispatch(setNglViewParams(NGL_PARAMS.fogNear, value, majorView, VIEWS.MAJOR_VIEW))}
onChange={(e, value) => dispatch(setNglFogNear(value, viewParams[NGL_PARAMS.fogNear], majorView))}
/>
</Grid>
</Grid>
Expand All @@ -129,7 +129,7 @@ export const SettingControls = memo(({ open, onClose }) => {
step={1}
min={0}
max={100}
onChange={(e, value) => dispatch(setNglViewParams(NGL_PARAMS.fogFar, value, majorView, VIEWS.MAJOR_VIEW))}
onChange={(e, value) => dispatch(setNglFogFar(value, viewParams[NGL_PARAMS.fogFar], majorView))}
/>
</Grid>
</Grid>
Expand Down
44 changes: 41 additions & 3 deletions js/reducers/ngl/actions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* Created by abradley on 03/03/2018.
*/
import { constant } from 'lodash';
import { constants } from '../selection/constants';
import { CONSTANTS } from './constants';

export const loadNglObject = (target, representations) => ({ type: CONSTANTS.LOAD_OBJECT, target, representations });
Expand Down Expand Up @@ -68,7 +66,47 @@ export const setNglClipNearAction = (newValue, oldValue) => {
oldValue: oldValue
}
};
}
};

export const setNglClipFarAction = (newValue, oldValue) => {
return {
type: CONSTANTS.SET_CLIP_FAR,
payload: {
newValue: newValue,
oldValue: oldValue
}
};
};

export const setNglClipDistAction = (newValue, oldValue) => {
return {
type: CONSTANTS.SET_CLIP_DIST,
payload: {
newValue: newValue,
oldValue: oldValue
}
};
};

export const setNglFogNearAction = (newValue, oldValue) => {
return {
type: CONSTANTS.SET_FOG_NEAR,
payload: {
newValue: newValue,
oldValue: oldValue
}
};
};

export const setNglFogFarAction = (newValue, oldValue) => {
return {
type: CONSTANTS.SET_FOG_FAR,
payload: {
newValue: newValue,
oldValue: oldValue
}
};
};

export const setNglOrientation = (orientation, div_id) => ({ type: CONSTANTS.SET_ORIENTATION, orientation, div_id });

Expand Down
6 changes: 5 additions & 1 deletion js/reducers/ngl/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ export const CONSTANTS = {
ADD_TO_PDB_CACHE: prefix + 'ADD_TO_PDB_CACHE',

SET_BACKGROUND_COLOR: prefix + 'SET_BACKGROUND_COLOR',
SET_CLIP_NEAR: prefix + 'SET_CLIP_NEAR'
SET_CLIP_NEAR: prefix + 'SET_CLIP_NEAR',
SET_CLIP_FAR: prefix + 'SET_CLIP_FAR',
SET_CLIP_DIST: prefix + 'SET_CLIP_DIST',
SET_FOG_NEAR: prefix + 'SET_FOG_NEAR',
SET_FOG_FAR: prefix + 'SET_FOG_FAR'
};

export const SCENES = {
Expand Down
26 changes: 25 additions & 1 deletion js/reducers/ngl/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import {
setNglOrientation,
setNglViewParams,
setBackgroundColor,
setNglClipNearAction
setNglClipNearAction,
setNglClipFarAction,
setNglClipDistAction,
setNglFogNearAction,
setNglFogFarAction
} from './actions';
import { isEmpty, isEqual } from 'lodash';
import { createRepresentationsArray } from '../../components/nglView/generatingObjects';
Expand Down Expand Up @@ -186,4 +190,24 @@ export const setNglBckGrndColor = (color, major, summary) => (dispatch, getState
export const setNglClipNear = (newValue, oldValue, major) => (dispatch, getState) => {
dispatch(setNglViewParams(NGL_PARAMS.clipNear, newValue, major, VIEWS.MAJOR_VIEW));
dispatch(setNglClipNearAction(newValue, oldValue));
};

export const setNglClipFar = (newValue, oldValue, major) => (dispatch, getState) => {
dispatch(setNglViewParams(NGL_PARAMS.clipFar, newValue, major, VIEWS.MAJOR_VIEW));
dispatch(setNglClipFarAction(newValue, oldValue));
};

export const setNglClipDist = (newValue, oldValue, major) => (dispatch, getState) => {
dispatch(setNglViewParams(NGL_PARAMS.clipDist, newValue, major, VIEWS.MAJOR_VIEW));
dispatch(setNglClipDistAction(newValue, oldValue));
};

export const setNglFogNear = (newValue, oldValue, major) => (dispatch, getState) => {
dispatch(setNglViewParams(NGL_PARAMS.fogNear, newValue, major, VIEWS.MAJOR_VIEW));
dispatch(setNglFogNearAction(newValue, oldValue));
};

export const setNglFogFar = (newValue, oldValue, major) => (dispatch, getState) => {
dispatch(setNglViewParams(NGL_PARAMS.fogFar, newValue, major, VIEWS.MAJOR_VIEW));
dispatch(setNglFogFarAction(newValue, oldValue));
};
6 changes: 5 additions & 1 deletion js/reducers/tracking/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ export const actionType = {
ALL_TURNED_ON_BY_TYPE: 'ALL_TURNED_ON_BY_TYPE',
ALL_TURNED_OFF_BY_TYPE: 'ALL_TURNED_OFF_BY_TYPE',
BACKGROUND_COLOR_CHANGED: 'BACKGROUND_COLOR_CHANGED',
CLIP_NEAR: 'CLIP_NEAR'
CLIP_NEAR: 'CLIP_NEAR',
CLIP_FAR: 'CLIP_FAR',
CLIP_DIST: 'CLIP_DIST',
FOG_NEAR: 'FOG_NEAR',
FOG_FAR: 'FOG_FAR'
};

export const actionDescription = {
Expand Down
35 changes: 34 additions & 1 deletion js/reducers/tracking/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,16 @@ import {
} from '../../../js/reducers/ngl/actions';
import * as listType from '../../constants/listTypes';
import { assignRepresentationToComp } from '../../components/nglView/generatingObjects';
import { deleteObject, setOrientation, setNglBckGrndColor, setNglClipNear } from '../../../js/reducers/ngl/dispatchActions';
import {
deleteObject,
setOrientation,
setNglBckGrndColor,
setNglClipNear,
setNglClipFar,
setNglClipDist,
setNglFogNear,
setNglFogFar
} from '../../../js/reducers/ngl/dispatchActions';
import {
setSendActionsList,
setIsActionsSending,
Expand Down Expand Up @@ -1256,6 +1265,18 @@ const handleUndoAction = (action, stages) => (dispatch, getState) => {
case actionType.CLIP_NEAR:
dispatch(setNglClipNear(action.oldSetting, action.newSetting, majorViewStage));
break;
case actionType.CLIP_FAR:
dispatch(setNglClipFar(action.oldSetting, action.newSetting, majorViewStage));
break;
case actionType.CLIP_DIST:
dispatch(setNglClipDist(action.oldSetting, action.newSetting, majorViewStage));
break;
case actionType.FOG_NEAR:
dispatch(setNglFogNear(action.oldSetting, action.newSetting, majorViewStage));
break;
case actionType.FOG_FAR:
dispatch(setNglFogFar(action.oldSetting, action.newSetting, majorViewStage));
break;
default:
break;
}
Expand Down Expand Up @@ -1363,6 +1384,18 @@ const handleRedoAction = (action, stages) => (dispatch, getState) => {
case actionType.CLIP_NEAR:
dispatch(setNglClipNear(action.newSetting, action.oldSetting, majorViewStage));
break;
case actionType.CLIP_FAR:
dispatch(setNglClipFar(action.newSetting, action.oldSetting, majorViewStage));
break;
case actionType.CLIP_DIST:
dispatch(setNglClipDist(action.newSetting, action.oldSetting, majorViewStage));
break;
case actionType.FOG_NEAR:
dispatch(setNglFogNear(action.newSetting, action.oldSetting, majorViewStage));
break;
case actionType.FOG_FAR:
dispatch(setNglFogFar(action.newSetting, action.oldSetting, majorViewStage));
break;
default:
break;
}
Expand Down
76 changes: 76 additions & 0 deletions js/reducers/tracking/trackingActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,82 @@ export const findTrackAction = (action, state) => {
},
text: `Clip near of NGL ${actionDescription.CHANGED} from value: ${oldSetting} to value: ${newSetting}`
};
} else if (action.type.includes(nglConstants.SET_CLIP_FAR)) {
let oldSetting = action.payload.oldValue;
let newSetting = action.payload.newValue;

trackAction = {
type: actionType.CLIP_FAR,
merge: true,
annotation: actionAnnotation.CHECK,
timestamp: Date.now(),
username: username,
object_type: 'NGL',
object_name: 'NGL',
oldSetting: oldSetting,
newSetting: newSetting,
getText: function() {
return "Clip far of NGL " + actionDescription.CHANGED + " from value: " + this.oldSetting + " to value: " + this.newSetting;
},
text: `Clip far of NGL ${actionDescription.CHANGED} from value: ${oldSetting} to value: ${newSetting}`
};
} else if (action.type.includes(nglConstants.SET_CLIP_DIST)) {
let oldSetting = action.payload.oldValue;
let newSetting = action.payload.newValue;

trackAction = {
type: actionType.CLIP_DIST,
merge: true,
annotation: actionAnnotation.CHECK,
timestamp: Date.now(),
username: username,
object_type: 'NGL',
object_name: 'NGL',
oldSetting: oldSetting,
newSetting: newSetting,
getText: function() {
return "Clip dist of NGL " + actionDescription.CHANGED + " from value: " + this.oldSetting + " to value: " + this.newSetting;
},
text: `Clip dist of NGL ${actionDescription.CHANGED} from value: ${oldSetting} to value: ${newSetting}`
};
} else if (action.type.includes(nglConstants.SET_FOG_NEAR)) {
let oldSetting = action.payload.oldValue;
let newSetting = action.payload.newValue;

trackAction = {
type: actionType.FOG_NEAR,
merge: true,
annotation: actionAnnotation.CHECK,
timestamp: Date.now(),
username: username,
object_type: 'NGL',
object_name: 'NGL',
oldSetting: oldSetting,
newSetting: newSetting,
getText: function() {
return "Fog near of NGL " + actionDescription.CHANGED + " from value: " + this.oldSetting + " to value: " + this.newSetting;
},
text: `For near of NGL ${actionDescription.CHANGED} from value: ${oldSetting} to value: ${newSetting}`
};
} else if (action.type.includes(nglConstants.SET_FOG_FAR)) {
let oldSetting = action.payload.oldValue;
let newSetting = action.payload.newValue;

trackAction = {
type: actionType.FOG_FAR,
merge: true,
annotation: actionAnnotation.CHECK,
timestamp: Date.now(),
username: username,
object_type: 'NGL',
object_name: 'NGL',
oldSetting: oldSetting,
newSetting: newSetting,
getText: function() {
return "Fog far of NGL " + actionDescription.CHANGED + " from value: " + this.oldSetting + " to value: " + this.newSetting;
},
text: `For far of NGL ${actionDescription.CHANGED} from value: ${oldSetting} to value: ${newSetting}`
};
}
}
return trackAction;
Expand Down

0 comments on commit 655ed84

Please sign in to comment.