Skip to content

Commit f850a8e

Browse files
hotzenklotzphilippottofm3
authored
Refactor TreeMap to DiffableMap (#8626)
* allow to toggle visibility of each segment via custom segment colors * allow to toggle segments and groups * linting * backend: add UpdateSegmentVisibilityVolumeAction, UpdateSegmentGroupVisibilityVolumeAction * integrate updateSegmentVisibility update action * implement toggle compaction and integrate updateSegmentGroupVisibilityVolumeAction * warn user when too many custom segment colors exist; don't show checkboxes if selective visibility is active * move titleRender to own method * implement hideUnregisteredSegments and only-show-this-segment etc in context menu * fix saving of hideUnregisteredSegments * fix typing * remove unlisted segments group prototype again * expose hide unlisted segments in left sidebar and add show-all-segments in context menu of data viewports * remove -2 handling for unlisted group stuff * fix visibility when removing segment from list; refactor toggling * hide checkboxes when proofreading and selectiveVisibilityInProofreading is active; fix screenshot tests * write and parse tree and segment isVisible in NMLs * fix support for view only * add missing volumetracing_action_helpers.ts module * fix warning because of non-string value in radio button component for tool bar * use fast tooltip to avoid findDOMNode warning * fmt backend * fix warning when opening context menu by restructuring hooks * refactor context info in context menu * lint * add some position when a segment is registered by toggling its visibility * update screenshots (the selective rendering is done via hovering where the opacity is a bit different now) * implement benchmark for segment list scrolling; improve perf a little bit * clean up unnecessary isChecked property * use extracted vars * add comments * linting * integrate some code rabbit feedback * format * added docstrings to DiffableMap * extended unit tests for diffable map * add missing type to merge * WIP refactor treemap as diffablemap * delete commented code * merge defaultDatasetViewConfiguration with defaultDatasetViewConfigurationOrNull * incorporate feedback * WIP refactor Treemaps as diffablemaps * WIP more refactoring * WIP more refactoring * WIP even more refactoring * fixed more stuff * update changelog * fix more tests * fix more tests * fix more tests and types * fix remaining tests * unify proto property setting using withIsVisible * fix array buffer related TS problems * fix remaining type errors * formatting * add Toast.info to global mocks * fix incorrect copy of TypedArray (buffer offsets may differ; slice is simpler anyway) * changelog * fix tree visibility toggle * fix tree group toggling * Update frontend/javascripts/viewer/view/right-border-tabs/connectome_tab/connectome_view.tsx Co-authored-by: Philipp Otto <philippotto@users.noreply.github.com> * Update frontend/javascripts/libs/diffable_map.ts Co-authored-by: Philipp Otto <philippotto@users.noreply.github.com> * Update frontend/javascripts/viewer/view/right-border-tabs/connectome_tab/connectome_view.tsx Co-authored-by: Philipp Otto <philippotto@users.noreply.github.com> * Update frontend/javascripts/viewer/model/reducers/skeletontracing_reducer.ts Co-authored-by: Philipp Otto <philippotto@users.noreply.github.com> * Update frontend/javascripts/libs/diffable_map.ts Co-authored-by: Philipp Otto <philippotto@users.noreply.github.com> * update can-i-use / browser capabilites list * add PR feedback * move tree type definitions into separate file to avoid cyclic dependency * misc fixes * clean unused code * add warnings to the mutable methods of diffable map * fix Object.values(props.trees) in three places, which TS did not complain about * more fixes * forbid usage of Object.keys/values/entries on DiffableMap and EdgeCollection to prevent errors * use toArray * use toArray instead of Array.from * convert more foreach to for loops * two more foreach -> for loop * use clone and mutableSet instead of repeated immutable sets * refactor chain reducer a bit * add reducer tests for toggling of trees and fix them * simplify chain reduce in tests * avoid ts-expect error --------- Co-authored-by: Philipp Otto <philipp.4096@gmail.com> Co-authored-by: Florian M <florian@scm.io> Co-authored-by: Philipp Otto <philippotto@users.noreply.github.com>
1 parent da0d52d commit f850a8e

File tree

79 files changed

+2896
-1977
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+2896
-1977
lines changed

CHANGELOG.unreleased.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
3030
- Updated to Typescript from version `5.5` to `5.8`. [#8613](https://github.com/scalableminds/webknossos/pull/8613)
3131
- Updated Voxelytics log streaming to also include the `log_path` attribute. [#8615](https://github.com/scalableminds/webknossos/pull/8615)
3232
- When creating or uploading a non-task volume annotation layer with a fallback segmentation layer, the annotation layer’s bounding box will now be limited to that layer’s, instead of the whole dataset’s. [#7580](https://github.com/scalableminds/webknossos/pull/7580)
33+
- Refactored the `skeletonTracing.TreeMap` structure to use `DiffableMap` type. [#8626](https://github.com/scalableminds/webknossos/pull/8626)
3334

3435
### Fixed
3536
- When selecting a skeleton node in a viewport, its tree is focused and scrolled to in the skeleton tab, even if its parent group was collapsed before. [#8585](https://github.com/scalableminds/webknossos/pull/8585)

frontend/javascripts/admin/dataset/composition_wizard/02_upload_files.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import ErrorHandling from "libs/error_handling";
66
import { readFileAsText } from "libs/read_file";
77
import Toast from "libs/toast";
88
import { SoftError } from "libs/utils";
9-
import * as Utils from "libs/utils";
109
import _ from "lodash";
1110
import type { Vector3 } from "viewer/constants";
1211
import { parseNml } from "viewer/model/helpers/nml_helpers";
@@ -175,13 +174,19 @@ async function parseNmlFiles(fileList: FileList): Promise<Partial<WizardContext>
175174
throw new SoftError("Could not extract dataset names.");
176175
}
177176

178-
if (Object.keys(trees1).length !== Object.keys(trees2).length) {
177+
if (trees1.keys().toArray().length !== trees2.keys().toArray().length) {
179178
throw new SoftError("The two NML files should have the same tree count.");
180179
}
181180

182181
for (const [tree1, tree2] of _.zip(
183-
Utils.values(trees1).sort((a, b) => a.treeId - b.treeId),
184-
Utils.values(trees2).sort((a, b) => a.treeId - b.treeId),
182+
trees1
183+
.values()
184+
.toArray()
185+
.sort((a, b) => a.treeId - b.treeId),
186+
trees2
187+
.values()
188+
.toArray()
189+
.sort((a, b) => a.treeId - b.treeId),
185190
)) {
186191
if (tree1 == null || tree2 == null) {
187192
// Satisfy TS. This should not happen, as we checked before that both tree collections

frontend/javascripts/libs/browser_feature_check.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default function checkBrowserFeatures() {
88
Object.fromEntries([]);
99
new BigUint64Array(1);
1010
"hello".replaceAll("l", "k");
11+
new Map([[1, 2]]).values().map((v) => v);
1112
[].at(0);
1213
} catch (exception) {
1314
Toast.warning(

frontend/javascripts/libs/cuckoo/abstract_cuckoo_table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let cachedNullTexture: UpdatableTexture | undefined;
1414
export abstract class AbstractCuckooTable<K, V, Entry extends [K, V]> {
1515
entryCapacity: number;
1616
entryCount: number = 0;
17-
protected table!: Uint32Array;
17+
protected table!: Uint32Array<ArrayBuffer>;
1818
protected seeds!: number[];
1919
protected seedSubscribers: Array<SeedSubscriberFn> = [];
2020
_texture: UpdatableTexture;

0 commit comments

Comments
 (0)