Skip to content

Commit

Permalink
jump to the center of the bounding box if find-data doesn't find data (
Browse files Browse the repository at this point in the history
…fixes #4287)
  • Loading branch information
philippotto committed Nov 27, 2019
1 parent 879df97 commit b322d91
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion frontend/javascripts/libs/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const Toast = {

if (type === "error") {
toastConfig = Object.assign(toastConfig, {
icon: <Icon type="cross-circle-o" className="alert-wiggle" style={{ color: "#a94442" }} />,
icon: <Icon type="close-circle-o" className="alert-wiggle" style={{ color: "#a94442" }} />,
style: {
backgroundColor: "#f2dede",
borderColor: "#ebccd1",
Expand Down
15 changes: 13 additions & 2 deletions frontend/javascripts/oxalis/view/settings/dataset_settings_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { Dispatch } from "redux";
import { connect } from "react-redux";
import * as React from "react";
import _ from "lodash";
import { V3 } from "libs/mjs";

import type { APIDataset, APIHistogramData } from "admin/api_flow_types";
import { AsyncIconButton } from "components/async_clickables";
Expand All @@ -20,7 +21,11 @@ import {
import { findDataPositionForLayer, getHistogramForLayer } from "admin/admin_rest_api";
import { getGpuFactorsWithLabels } from "oxalis/model/bucket_data_handling/data_rendering_logic";
import { getMaxZoomValueForResolution } from "oxalis/model/accessors/flycam_accessor";
import { hasSegmentation, getElementClass } from "oxalis/model/accessors/dataset_accessor";
import {
hasSegmentation,
getElementClass,
getLayerBoundaries,
} from "oxalis/model/accessors/dataset_accessor";
import { setPositionAction, setZoomStepAction } from "oxalis/model/actions/flycam_actions";
import {
updateDatasetSettingAction,
Expand Down Expand Up @@ -307,7 +312,13 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
layerName,
);
if (!position || !resolution) {
Toast.warning(`Couldn't find data within layer "${layerName}."`);
const { upperBoundary, lowerBoundary } = getLayerBoundaries(dataset, layerName);
const centerPosition = V3.add(lowerBoundary, upperBoundary).map(el => el / 2);

Toast.warning(
`Couldn't find data within layer "${layerName}." Jumping to the center of the layer's bounding box.`,
);
this.props.onSetPosition(centerPosition);
return;
}

Expand Down

0 comments on commit b322d91

Please sign in to comment.