-
Notifications
You must be signed in to change notification settings - Fork 18
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
Segment group batch actions #7164
Merged
Merged
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
4e86f6d
start: change group color
dieknolle3333 b97c9d8
change group color
dieknolle3333 ea18ffd
[very broken] first implementation to hide/load all meshes of a segme…
dieknolle3333 98e458f
show/hide all msehes for group
dieknolle3333 071d0e1
add batch actions: download, show/hide, load meshes for segment group
dieknolle3333 d2d8861
fix code duplication and lint
dieknolle3333 e6ed640
add warning if position of segments in unknown
dieknolle3333 5472e53
push WIP before I leave
dieknolle3333 0a4c7d2
zip multiple meshes
dieknolle3333 31c3f87
undo zip.js upgrade
dieknolle3333 e829f1e
batch actions to set colour and remove and refresh meshes option
dieknolle3333 0f0f402
Merge branch 'master' into segment-group-batch-actions
dieknolle3333 c879a10
lint
dieknolle3333 e0440d3
remove TODOs
dieknolle3333 8cab227
add chagelog entry
dieknolle3333 ea8b1c9
refactor code
dieknolle3333 5944d85
WIP: start refactoring
dieknolle3333 8781956
WIP: add helper method
dieknolle3333 e809bca
WIP: address review
dieknolle3333 ca20df1
WIP: add lost method call
dieknolle3333 a4b89e2
WIP: trying to improve areSegmentsInGroupVisible
dieknolle3333 b5a2e99
WIP: fix getDerivedStateFromProps
dieknolle3333 9db1f1e
veryWIP: trying to fix tests by mocking zipjs
dieknolle3333 6c7bedd
WIP: trying to fix tests
dieknolle3333 cc866f5
WIP: fix small typo
dieknolle3333 c8ca503
fix merge conflicts
dieknolle3333 180bddb
WIP: trying to fix tests again
dieknolle3333 b9a11ed
WIP: trying to fix tests again
dieknolle3333 4939928
WIP: trying to fix tests (I really hope its the last time)
dieknolle3333 5f872b1
fix comment
dieknolle3333 ecdf655
change order of menu items
dieknolle3333 fc65635
Merge branch 'master' into segment-group-batch-actions
dieknolle3333 f3156ea
WIP: address PR review
dieknolle3333 1198f1d
WIP: address refactoring
dieknolle3333 9c1c06f
WIP: change icons
dieknolle3333 cdf453a
address review and lint
dieknolle3333 2803c61
merge master
dieknolle3333 76a09af
fix capitalization
dieknolle3333 720e052
fix spacing
dieknolle3333 bb1e286
fx method name
dieknolle3333 3baa2aa
fix icon spacing
dieknolle3333 caa361a
Merge branch 'master' into segment-group-batch-actions
dieknolle3333 a78963f
improve typing
philippotto bebb08f
Merge branch 'segment-group-batch-actions' of github.com:scalablemind…
philippotto a4dd2cd
WIP: fix spacing of font awesome icons and fix linting
dieknolle3333 e3892db
Merge branch 'segment-group-batch-actions' of github.com:scalablemind…
dieknolle3333 4d35fca
address review
dieknolle3333 eef4546
remove TODO comment and improve naming
dieknolle3333 414455e
Merge branch 'master' into segment-group-batch-actions
dieknolle3333 41034cc
merge master
dieknolle3333 eddc45e
merge master
dieknolle3333 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,10 @@ import { | |
SettingOutlined, | ||
ExclamationCircleOutlined, | ||
ArrowRightOutlined, | ||
CloudDownloadOutlined, | ||
DownloadOutlined, | ||
SearchOutlined, | ||
EyeInvisibleOutlined, | ||
EyeOutlined, | ||
DatabaseOutlined, | ||
} from "@ant-design/icons"; | ||
import type RcTree from "rc-tree"; | ||
import { getJobs, startComputeMeshFileJob } from "admin/admin_rest_api"; | ||
|
@@ -420,23 +418,23 @@ class SegmentsView extends React.Component<Props, State> { | |
}; | ||
} | ||
if (prevState.prevProps?.isosurfaces !== isosurfaces) { | ||
//if any segment is invisible, set visibility false, so that the first action is to make all meshes visible | ||
// Derive the areSegmentsInGroupVisible state so that we know per group | ||
// if it contains only visible elements. This is used to know whether "Show meshes" or | ||
// "Hide meshes" context item should be shown. | ||
// If any segment is invisible, set the visibility of the group to false, so that the preferred | ||
// action is to make all meshes visible. | ||
const newVisibleMap: { [groupId: number]: boolean } = {}; | ||
const segmentGroupsWithRoot = [...segmentGroups, rootGroup]; | ||
segmentGroupsWithRoot.forEach((group) => { | ||
let isVisible = true; | ||
const segmentsOfGroup = groupToSegmentsMap[group.groupId]; | ||
if (segmentsOfGroup == null) return; | ||
const visibilityOfSegments: number[] = segmentsOfGroup.map((segment) => { | ||
const isSomeSegmentLoadedAndInvisible = segmentsOfGroup.some((segment) => { | ||
const segmentIsosurface = isosurfaces[segment.id]; | ||
if (segmentIsosurface == null) return 1; //only care about explicitly invisible (not unloaded) meshes | ||
return isosurfaces[segment.id].isVisible ? 1 : 0; | ||
// Only regard loaded, but invisible meshes | ||
return segmentIsosurface != null && !isosurfaces[segment.id].isVisible; | ||
}); | ||
if (_.sum(visibilityOfSegments) < segmentsOfGroup.length) { | ||
//at least one is invisible, so first option is to make every mesh visible | ||
isVisible = false; | ||
} | ||
newVisibleMap[group.groupId] = isVisible; | ||
|
||
newVisibleMap[group.groupId] = !isSomeSegmentLoadedAndInvisible; | ||
}); | ||
return { | ||
...updateStateObject, //may be null | ||
|
@@ -1098,41 +1096,21 @@ class SegmentsView extends React.Component<Props, State> { | |
Store.dispatch(updateIsosurfaceVisibilityAction(layerName, segment.id, isVisible)); | ||
} | ||
}); | ||
|
||
const newSegmentsInGroupVisible = { | ||
...this.state.areSegmentsInGroupVisible, | ||
[groupId]: isVisible, | ||
}; | ||
this.setState({ | ||
areSegmentsInGroupVisible: newSegmentsInGroupVisible, | ||
}); | ||
}; | ||
|
||
handleLoadMeshesAdHoc = (groupId: number) => { | ||
this.handlePerSegment(groupId, (segment) => { | ||
if (segment.somePosition == null) return; | ||
this.props.loadAdHocMesh(segment.id, segment.somePosition); | ||
}); | ||
|
||
const newSegmentsInGroupVisible = { | ||
...this.state.areSegmentsInGroupVisible, | ||
[groupId]: true, | ||
}; | ||
this.setState({ | ||
areSegmentsInGroupVisible: newSegmentsInGroupVisible, | ||
}); | ||
}; | ||
|
||
getSegmentsWithMissingLocation = (groupId: number): number[] => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd replace |
||
const segmentGroup = this.getSegmentsOfGroup(groupId); | ||
if (segmentGroup == null) return []; | ||
let segmentsWithoutPosition: number[] = segmentGroup.reduce( | ||
(segmentsWithoutPositionAcc: number[], segment: Segment) => { | ||
segment.somePosition == null && segmentsWithoutPositionAcc.push(segment.id); | ||
return segmentsWithoutPositionAcc; | ||
}, | ||
[], | ||
); | ||
let segmentsWithoutPosition: number[] = segmentGroup | ||
.filter((segment) => segment.somePosition == null) | ||
.map((segment) => segment.id); | ||
return segmentsWithoutPosition.sort(); | ||
}; | ||
|
||
|
@@ -1153,14 +1131,6 @@ class SegmentsView extends React.Component<Props, State> { | |
this.props.currentMeshFile.meshFileName, | ||
); | ||
}); | ||
|
||
const newSegmentsInGroupVisible = { | ||
...this.state.areSegmentsInGroupVisible, | ||
[groupId]: true, | ||
}; | ||
this.setState({ | ||
areSegmentsInGroupVisible: newSegmentsInGroupVisible, | ||
}); | ||
}; | ||
|
||
downloadAllMeshesForGroup = (groupId: number) => { | ||
|
@@ -1442,8 +1412,7 @@ class SegmentsView extends React.Component<Props, State> { | |
// does not work properly. See https://github.com/react-component/trigger/issues/106#issuecomment-948532990 | ||
// @ts-expect-error ts-migrate(2322) FIXME: Type '{ children: Element; overlay: () => Element;... Remove this comment to see the full error message | ||
autoDestroy | ||
open | ||
/* open={this.state.activeDropdownSegmentOrGroupId === id} */ // explicit visibility handling is required here otherwise the color picker component for "Change Group color" is rendered/positioned incorrectly | ||
open={this.state.activeDropdownSegmentOrGroupId === id} // explicit visibility handling is required here otherwise the color picker component for "Change Group color" is rendered/positioned incorrectly | ||
onOpenChange={(isVisible) => | ||
this.handleSegmentDropdownMenuVisibility(id, isVisible) | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I understand the reason for this code. Can you elaborate please. How can I test this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code makes sure that changing the visibility of a mesh (e.g. by clicking the checkbox) gets noticed by the segments_view as the visibility is part of the isosurface.
This is needed because I toggle the "Hide/Show meshes" option based on the mesh visibility in the group.
You can test it by loading all meshes in a group. Now, the context menu should say "Hide...". If you deselect any mesh's visibility checkbox, the context menu notices and will then read "Show all meshes".
Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also see philipps comment for this: #7164 (review)