diff --git a/web/app/cad/actions/usabilityActions.js b/web/app/cad/actions/usabilityActions.js index 45a737df..a22486a7 100644 --- a/web/app/cad/actions/usabilityActions.js +++ b/web/app/cad/actions/usabilityActions.js @@ -142,5 +142,23 @@ export default [ ctx.services.viewer.requestRender(); } }, - + { + id: 'StandardView3Way', + invoke: ctx => { + ctx.services.viewer.lookAt(ORIGIN, DIR_3_WAY_VIEW, AXIS.Y, ctx.services.viewer.sceneSetup.camera.position.length()); + ctx.services.viewer.requestRender(); + } + }, + { + id: 'HistoryBackward', + invoke: ctx => ctx.services.craft.historyTravel.backward({ + noWizardFocus: true + }) + }, + { + id: 'HistoryForward', + invoke: ctx => ctx.services.craft.historyTravel.forward({ + noWizardFocus: true + }) + }, ] \ No newline at end of file diff --git a/web/app/cad/craft/craftPlugin.js b/web/app/cad/craft/craftPlugin.js index 4f6fbe7c..d51727e5 100644 --- a/web/app/cad/craft/craftPlugin.js +++ b/web/app/cad/craft/craftPlugin.js @@ -79,7 +79,8 @@ export function activate({streams, services}) { } services.craft = { - modify, modifyInHistoryAndStep, reset, runRequest + modify, modifyInHistoryAndStep, reset, runRequest, + historyTravel: historyTravel(streams.craft.modifications) }; streams.craft.modifications.pairwise().attach(([prev, curr]) => { @@ -129,3 +130,30 @@ function isAdditiveChange({history:oldHistory, pointer:oldPointer}, {history, po } return true; } + +function historyTravel(modifications$) { + + return { + setPointer: function(pointer, hints) { + let mod = modifications$.value; + if (pointer >= mod.history.length || pointer < -1) { + return; + } + modifications$.update(({history}) => ({history, pointer, hints})); + }, + begin: function(hints) { + this.setPointer(-1, hints); + }, + end: function(hints) { + this.setPointer(modifications$.value.history.length - 1, hints); + }, + forward: function(hints) { + this.setPointer(modifications$.value.pointer + 1, hints); + }, + backward: function (hints) { + this.setPointer(modifications$.value.pointer - 1, hints); + }, + } + +} + diff --git a/web/app/cad/craft/wizard/components/Wizard.jsx b/web/app/cad/craft/wizard/components/Wizard.jsx index 3c408af7..12b2d550 100644 --- a/web/app/cad/craft/wizard/components/Wizard.jsx +++ b/web/app/cad/craft/wizard/components/Wizard.jsx @@ -90,6 +90,9 @@ export default class Wizard extends React.Component { }; focusFirstInput = el => { + if (this.props.noFocus) { + return; + } let toFocus = el.querySelector('input, select'); if (!toFocus) { toFocus = el; diff --git a/web/app/cad/craft/wizard/components/WizardManager.jsx b/web/app/cad/craft/wizard/components/WizardManager.jsx index c55cfeeb..97fdd810 100644 --- a/web/app/cad/craft/wizard/components/WizardManager.jsx +++ b/web/app/cad/craft/wizard/components/WizardManager.jsx @@ -11,6 +11,7 @@ function WizardManager({wizardContext, type, cancel, cancelHistoryEdit, applyWor } return } diff --git a/web/app/cad/craft/wizard/wizardPlugin.js b/web/app/cad/craft/wizard/wizardPlugin.js index 3ccac786..05b836bc 100644 --- a/web/app/cad/craft/wizard/wizardPlugin.js +++ b/web/app/cad/craft/wizard/wizardPlugin.js @@ -28,12 +28,13 @@ export function activate(ctx) { } }); - function gotoEditHistoryModeIfNeeded({pointer, history}) { + function gotoEditHistoryModeIfNeeded({pointer, history, hints}) { if (pointer !== history.length - 1) { let {type, params} = history[pointer + 1]; streams.wizard.effectiveOperation.value = { type, params, + noWizardFocus: hints && hints.noWizardFocus, changingHistory: true }; } else { @@ -56,7 +57,7 @@ export function activate(ctx) { let operation = ctx.services.operation.get(opRequest.type); let params; - let changingHistory = opRequest.changingHistory; + let {changingHistory, noWizardFocus} = opRequest; if (changingHistory) { params = clone(opRequest.params) } else { @@ -98,7 +99,7 @@ export function activate(ctx) { const disposerList = createFunctionList(); wizCtx = { workingRequest$, materializedWorkingRequest$, state$, updateParams, updateParam, updateState, - operation, changingHistory, + operation, changingHistory, noWizardFocus, addDisposer: disposerList.add, dispose: disposerList.call, ID: ++REQUEST_COUNTER, diff --git a/web/app/cad/keyboard/keymaps/default.js b/web/app/cad/keyboard/keymaps/default.js index cb52eaba..75f8fd5d 100644 --- a/web/app/cad/keyboard/keymaps/default.js +++ b/web/app/cad/keyboard/keymaps/default.js @@ -16,6 +16,8 @@ export default { 'StandardViewTop': '5', 'StandardViewBottom': '6', 'StandardView3Way': '7', + 'HistoryBackward': ',', + 'HistoryForward': '.', 'menu.craft': 'shift+c', 'menu.primitives': 'shift+a', 'menu.main': 'space',