Skip to content

Commit

Permalink
Add brush size settings and shortcuts (#3126)
Browse files Browse the repository at this point in the history
* added brush size to the settings in volume tracing; added shift plus i/o as a shortcut for changing the brush size

* added new shortcut to the shortcut docs

* fixed flow error

* added changelog entry

* corrected typo
  • Loading branch information
MichaelBuessemeyer authored Aug 29, 2018
1 parent 492d7a0 commit bfaf55e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).

- Improved security by enabling http security headers [#3084](https://github.com/scalableminds/webknossos/pull/3084)
- Added the possibility to write markdown in the annotation description. [#3081](https://github.com/scalableminds/webknossos/pull/3081)
- Added the brush size to the settings on the left in volume tracing. The size can now also be adjusted by using only the keyboard. [#3126](https://github.com/scalableminds/webknossos/pull/3126)
- Added a user documentation for webKnossos [#3011](https://github.com/scalableminds/webknossos/pull/3011)

### Changed
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/admin/help/keyboardshortcut_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ const KeyboardShortcutView = () => {
action: "Toggle Move / Trace / Brush Mode",
},
{
keybinding: "Shift + Mousewheel",
keybinding: "Shift + Mousewheel or Shift + I,O",
action: "Change Brush Size (Brush Mode)",
},
{
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/oxalis/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ const Constants = {
MIN_SCALE: 0.5,
MAX_SCALE: 20,

MIN_BRUSH_SIZE: 5,
MAX_BRUSH_SIZE: 5000,

// The node radius is the actual radius of the node in nm, it's dependent on zoom and dataset scale
MIN_NODE_RADIUS: 1,
MAX_NODE_RADIUS: 5000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ class PlaneController extends React.PureComponent<Props> {
"shift + f": (timeFactor, first) => this.moveZ(getMoveValue(timeFactor) * 5, first),
"shift + d": (timeFactor, first) => this.moveZ(-getMoveValue(timeFactor) * 5, first),

"shift + i": () => this.changeBrushSizeIfBrushIsActive(-5),
"shift + o": () => this.changeBrushSizeIfBrushIsActive(5),

"shift + space": (timeFactor, first) => this.moveZ(-getMoveValue(timeFactor), first),
"ctrl + space": (timeFactor, first) => this.moveZ(-getMoveValue(timeFactor), first),
space: (timeFactor, first) => this.moveZ(getMoveValue(timeFactor), first),
Expand Down Expand Up @@ -546,6 +549,16 @@ class PlaneController extends React.PureComponent<Props> {
Toast.success(moveValueMessage, { key: "CHANGED_MOVE_VALUE" });
}

changeBrushSizeIfBrushIsActive(changeValue: number) {
const isBrushActive = Utils.maybe(getVolumeTool)(this.props.tracing.volume)
.map(tool => tool === VolumeToolEnum.BRUSH)
.getOrElse(false);
if (isBrushActive) {
const currentSize = Store.getState().temporaryConfiguration.brushSize;
Store.dispatch(setBrushSizeAction(currentSize + changeValue));
}
}

scrollPlanes(delta: number, type: ?ModifierKeys): void {
switch (type) {
case null: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import {
setActiveTreeAction,
setNodeRadiusAction,
} from "oxalis/model/actions/skeletontracing_actions";
import { setActiveCellAction } from "oxalis/model/actions/volumetracing_actions";
import {
setActiveCellAction,
setBrushSizeAction,
} from "oxalis/model/actions/volumetracing_actions";
import {
NumberInputSetting,
SwitchSetting,
Expand Down Expand Up @@ -51,8 +54,10 @@ type UserSettingsViewProps = {
onChangeBoundingBox: (value: ?Vector6) => void,
onChangeRadius: (value: number) => void,
onChangeZoomStep: (value: number) => void,
onChangeBrushSize: (value: number) => void,
viewMode: ModeType,
controlMode: ControlModeType,
brushSize: number,
};

class UserSettingsView extends PureComponent<UserSettingsViewProps> {
Expand Down Expand Up @@ -280,6 +285,15 @@ class UserSettingsView extends PureComponent<UserSettingsViewProps> {
const volumeTracing = enforceVolumeTracing(this.props.tracing);
panels.push(
<Panel header="Volume Options" key="3b">
<LogSliderSetting
label="Brush Size"
roundTo={0}
min={Constants.MIN_BRUSH_SIZE}
max={Constants.MAX_BRUSH_SIZE}
step={5}
value={this.props.brushSize}
onChange={this.props.onChangeBrushSize}
/>
<NumberInputSetting
label="Active Cell ID"
value={volumeTracing.activeCellId}
Expand Down Expand Up @@ -358,6 +372,7 @@ const mapStateToProps = (state: OxalisState) => ({
maxZoomStep: getMaxZoomStep(state),
viewMode: state.temporaryConfiguration.viewMode,
controlMode: state.temporaryConfiguration.controlMode,
brushSize: state.temporaryConfiguration.brushSize,
});

const mapDispatchToProps = (dispatch: Dispatch<*>) => ({
Expand All @@ -373,6 +388,10 @@ const mapDispatchToProps = (dispatch: Dispatch<*>) => ({
onChangeActiveCellId(id: number) {
dispatch(setActiveCellAction(id));
},
onChangeBrushSize(size: number) {
console.log(`called with size: ${size}`);
dispatch(setBrushSizeAction(size));
},
onChangeBoundingBox(boundingBox: ?Vector6) {
dispatch(setUserBoundingBoxAction(Utils.computeBoundingBoxFromArray(boundingBox)));
},
Expand Down

0 comments on commit bfaf55e

Please sign in to comment.