Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turning off recording when leaving arbitrary modes #4211

Merged
merged 8 commits into from
Aug 12, 2019
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).
### Changed
- Volume project download zips are reorganized to contain a zipfile for each annotation (that in turn contains a data.zip and an nml file). [#4167](https://github.com/scalableminds/webknossos/pull/4167)
- Team managers and admins can now get tasks that they had previously cancelled. [#4088](https://github.com/scalableminds/webknossos/pull/4088)
- Recording is now automatically turned off when switching from flight/oblique to orthogonal mode to prevent accidental node creation when switching back later. [#4211](https://github.com/scalableminds/webknossos/pull/4211)

### Fixed
- Fixed a bug where volume tracings could not be converted to hybrid. [#4159](https://github.com/scalableminds/webknossos/pull/4159)
Expand All @@ -59,7 +60,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).

### Highlights
- Added a histogram and min- / max-sliders to the dataset settings for each layer. This replaces the brightness and contrast settings. [#4105](https://github.com/scalableminds/webknossos/pull/4105)
- Added the possbility to enforce a certain magnification range for tasks (can be configured in the corresponding task type). [#4101](https://github.com/scalableminds/webknossos/pull/4101)
- Added the possibility to enforce a certain magnification range for tasks (can be configured in the corresponding task type). [#4101](https://github.com/scalableminds/webknossos/pull/4101)
- Added the possibility for admins to add experience domains while creating new tasks. [#4119](https://github.com/scalableminds/webknossos/pull/4119)

### Added
Expand Down
39 changes: 34 additions & 5 deletions frontend/javascripts/oxalis/view/action-bar/view_modes_view.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,46 @@
// @flow
import { Select } from "antd";
import { connect } from "react-redux";
import type { Dispatch } from "redux";
import React, { PureComponent } from "react";

import { setViewModeAction } from "oxalis/model/actions/settings_actions";
import {
setViewModeAction,
setFlightmodeRecordingAction,
} from "oxalis/model/actions/settings_actions";

import Store, { type OxalisState, type AllowedMode } from "oxalis/store";
import * as Utils from "libs/utils";
import constants, { type ViewMode } from "oxalis/constants";

const Option = Select.Option;
const { Option } = Select;

type Props = {|
type StateProps = {|
viewMode: ViewMode,
allowedModes: Array<AllowedMode>,
|};

type DispatchProps = {|
onChangeFlightmodeRecording: boolean => void,
|};

type Props = {| ...StateProps, ...DispatchProps |};

class ViewModesView extends PureComponent<Props, {}> {
blurElement = (event: SyntheticInputEvent<>) => {
event.target.blur();
};

handleChange = (mode: ViewMode) => {
// If we switch back from any arbitrary mode we stop recording.
// This prevents that when the user switches back to any arbitrary mode,
// a new node is instantly created at the screen's center.
if (
constants.MODES_ARBITRARY.includes(this.props.viewMode) &&
mode === constants.MODE_PLANE_TRACING
) {
this.props.onChangeFlightmodeRecording(false);
}
Store.dispatch(setViewModeAction(mode));

// Unfortunately, antd doesn't provide the original event here
Expand Down Expand Up @@ -55,11 +75,20 @@ class ViewModesView extends PureComponent<Props, {}> {
}
}

function mapStateToProps(state: OxalisState): Props {
const mapDispatchToProps = (dispatch: Dispatch<*>) => ({
onChangeFlightmodeRecording(value: boolean) {
dispatch(setFlightmodeRecordingAction(value));
},
});

function mapStateToProps(state: OxalisState): StateProps {
return {
viewMode: state.temporaryConfiguration.viewMode,
allowedModes: state.tracing.restrictions.allowedModes,
};
}

export default connect<Props, {||}, _, _, _, _>(mapStateToProps)(ViewModesView);
export default connect<Props, {||}, _, _, _, _>(
mapStateToProps,
mapDispatchToProps,
)(ViewModesView);