From 655ed849291e5136ea4bde0c404f1ea8970b9336 Mon Sep 17 00:00:00 2001 From: Boris Kovar Date: Wed, 20 Jan 2021 13:01:36 +0100 Subject: [PATCH] - finished implementation --- .../viewerControls/settingsControls.js | 10 +-- js/reducers/ngl/actions.js | 44 ++++++++++- js/reducers/ngl/constants.js | 6 +- js/reducers/ngl/dispatchActions.js | 26 ++++++- js/reducers/tracking/constants.js | 6 +- js/reducers/tracking/dispatchActions.js | 35 ++++++++- js/reducers/tracking/trackingActions.js | 76 +++++++++++++++++++ 7 files changed, 191 insertions(+), 12 deletions(-) diff --git a/js/components/preview/viewerControls/settingsControls.js b/js/components/preview/viewerControls/settingsControls.js index 64e44d355..a42a69f3e 100644 --- a/js/components/preview/viewerControls/settingsControls.js +++ b/js/components/preview/viewerControls/settingsControls.js @@ -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'; @@ -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))} /> @@ -98,7 +98,7 @@ export const SettingControls = memo(({ open, onClose }) => { 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} /> @@ -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))} /> @@ -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))} /> diff --git a/js/reducers/ngl/actions.js b/js/reducers/ngl/actions.js index 1c179d129..e58f5e040 100644 --- a/js/reducers/ngl/actions.js +++ b/js/reducers/ngl/actions.js @@ -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 }); @@ -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 }); diff --git a/js/reducers/ngl/constants.js b/js/reducers/ngl/constants.js index bd9eb39de..4ef07ef26 100644 --- a/js/reducers/ngl/constants.js +++ b/js/reducers/ngl/constants.js @@ -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 = { diff --git a/js/reducers/ngl/dispatchActions.js b/js/reducers/ngl/dispatchActions.js index e2440f446..f6677442c 100644 --- a/js/reducers/ngl/dispatchActions.js +++ b/js/reducers/ngl/dispatchActions.js @@ -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'; @@ -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)); }; \ No newline at end of file diff --git a/js/reducers/tracking/constants.js b/js/reducers/tracking/constants.js index 20f0681cb..0a9998cf4 100644 --- a/js/reducers/tracking/constants.js +++ b/js/reducers/tracking/constants.js @@ -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 = { diff --git a/js/reducers/tracking/dispatchActions.js b/js/reducers/tracking/dispatchActions.js index 8d86f66af..88dafa56c 100644 --- a/js/reducers/tracking/dispatchActions.js +++ b/js/reducers/tracking/dispatchActions.js @@ -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, @@ -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; } @@ -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; } diff --git a/js/reducers/tracking/trackingActions.js b/js/reducers/tracking/trackingActions.js index eeaa48684..331f96752 100644 --- a/js/reducers/tracking/trackingActions.js +++ b/js/reducers/tracking/trackingActions.js @@ -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;