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

Fix bugs related to mesh loading and short links #7507

Merged
merged 4 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- The settings page for non-wkw datasets no longer shows a wall of non-applying errors. [#7475](https://github.com/scalableminds/webknossos/pull/7475)
- Fixed a bug where dataset deletion for ND datasets and datasets with coordinate transforms would not free the name even if no referencing annotations exist. [#7495](https://github.com/scalableminds/webknossos/pull/7495)
- Fixed a bug where the URL in the sharing link was wrongly decoded before encoding into a URI. [#7502](https://github.com/scalableminds/webknossos/pull/7502)
- Fixed a bug where loaded meshes were not encoded in the sharing link. [#7507](https://github.com/scalableminds/webknossos/pull/7507)
- Fixed a bug where meshes (or chunks of them) were always colored white, if they were loaded while the corresponding segmentation layer was disabled. [#7507](https://github.com/scalableminds/webknossos/pull/7507)
- Fixed a race condition when opening a short link, that would sometimes lead to an error toast. [#7507](https://github.com/scalableminds/webknossos/pull/7507)

### Removed

Expand Down
7 changes: 6 additions & 1 deletion frontend/javascripts/components/redirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ class AsyncRedirect extends React.PureComponent<Props> {
if (newPath.startsWith(location.origin)) {
// The link is absolute which react-router does not support
// apparently. See https://stackoverflow.com/questions/42914666/react-router-external-link
location.replace(newPath);
if (this.props.pushToHistory) {
location.assign(newPath);
} else {
location.replace(newPath);
}
return;
}

if (this.props.pushToHistory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export default class SegmentMeshController {
);
}

constructMesh(segmentId: number, geometry: THREE.BufferGeometry) {
const color = this.getColorObjectForSegment(segmentId);
constructMesh(segmentId: number, layerName: string, geometry: THREE.BufferGeometry) {
const color = this.getColorObjectForSegment(segmentId, layerName);
const meshMaterial = new THREE.MeshLambertMaterial({
color,
});
Expand Down Expand Up @@ -127,7 +127,7 @@ export default class SegmentMeshController {
targetGroup.scale.copy(new THREE.Vector3(...scale));
}
}
const mesh = this.constructMesh(segmentationId, geometry);
const mesh = this.constructMesh(segmentationId, layerName, geometry);
if (offset) {
mesh.translateX(offset[0]);
mesh.translateY(offset[1]);
Expand Down Expand Up @@ -179,7 +179,7 @@ export default class SegmentMeshController {
}

setMeshColor(id: number, layerName: string): void {
const color = this.getColorObjectForSegment(id);
const color = this.getColorObjectForSegment(id, layerName);
// if in nd-dataset, set the color for all additional coordinates
for (const recordsOfLayers of Object.values(this.meshesGroupsPerSegmentationId)) {
const meshDataForOneSegment = recordsOfLayers[layerName][id];
Expand All @@ -192,8 +192,8 @@ export default class SegmentMeshController {
}
}

getColorObjectForSegment(segmentId: number) {
const [hue, saturation, light] = getSegmentColorAsHSLA(Store.getState(), segmentId);
getColorObjectForSegment(segmentId: number, layerName: string) {
const [hue, saturation, light] = getSegmentColorAsHSLA(Store.getState(), segmentId, layerName);
const color = new THREE.Color().setHSL(hue, 0.75 * saturation, light / 10);
return color;
}
Expand Down
6 changes: 4 additions & 2 deletions frontend/javascripts/oxalis/controller/url_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
additionalCoordinateToKeyValue,
parseAdditionalCoordinateKey,
} from "oxalis/model/helpers/nml_helpers";
import { getMeshesForCurrentAdditionalCoordinates } from "oxalis/model/accessors/volumetracing_accessor";

const MAX_UPDATE_INTERVAL = 1000;
const MINIMUM_VALID_CSV_LENGTH = 5;
Expand Down Expand Up @@ -272,11 +273,12 @@ class UrlManager {
}

for (const layerName of Object.keys(state.localSegmentationData)) {
const { meshes: localMeshes, currentMeshFile } = state.localSegmentationData[layerName];
const { currentMeshFile } = state.localSegmentationData[layerName];
const currentMeshFileName = currentMeshFile?.meshFileName;
const localMeshes = getMeshesForCurrentAdditionalCoordinates(state, layerName);
const meshes =
localMeshes != null
? Utils.values(localMeshes as Record<number, MeshInformation>)
? Utils.values(localMeshes)
.filter(({ isVisible }) => isVisible)
.map(mapMeshInfoToUrlMeshDescriptor)
: [];
Expand Down
2 changes: 1 addition & 1 deletion frontend/javascripts/oxalis/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ export type OxalisState = {
readonly localSegmentationData: Record<
string, //layerName
{
//for meshes, the string represents additional coordinates, number is the segment ID.
// For meshes, the string represents additional coordinates, number is the segment ID.
// The undefined types were added to enforce null checks when using this structure.
readonly meshes: Record<string, Record<number, MeshInformation> | undefined> | undefined;
readonly availableMeshFiles: Array<APIMeshFile> | null | undefined;
Expand Down